the program should create a number of threads and have each thread test a portion of the numbers for primeness. That is, suppose the user enters the value 5000. And one thread finds the primes between 0 and 1000, and another thread finds the primes between 1000 and 2000 etc.
in C++ has a set class that is very similar to the TreeSet that is in the Java library. It is a templated class so when you declare a set you have to give the type of data that the set will hold. So you might say: set<int> example; Your threads will be testing integers to see if they are prime. If a number is prime it should be added to your set. The C++ set class is implemented using a tree in the same way that the Java TreeSet is implemented. The data in the set is kept in sorted order. Each time you insert a new value into the set the set is modified and pointers are changed. Therefore adding an element to a set is a critical section and can be protected with a mutex.
Đã trao cho:
expert in c++ and Java, written many multi threading applications , this is VERY simple. Relevant Skills and Experience c++ expert, multi threading game design Proposed Milestones $50 USD - whole project