Each task is simply to check whether x[i] is prime or not. A thread gets assigned a piece of work by taking the number need to be check at index i which is indicated by the counter. This ensures that every number is checked once and only once due to atomic increment.
This comment was marked helpful 0 times.
pebbled
By drawing new numbers whenever they have finished their work, all threads are kept busy, much as if they were pulling jobs off of a queue.
Each task is simply to check whether
x[i]
is prime or not. A thread gets assigned a piece of work by taking the number need to be check at indexi
which is indicated by the counter. This ensures that every number is checked once and only once due to atomic increment.This comment was marked helpful 0 times.
By drawing new numbers whenever they have finished their work, all threads are kept busy, much as if they were pulling jobs off of a queue.
This comment was marked helpful 0 times.