We haven't done too much with threading here at Problemotd so let's change that. Today's objective is to create a program that spawns several random number generators. Each random number generator will generate a random number between 1 and 100 and add it to a shared variable which is initialized at 0. Once that shared variable reaches a prime number greater than 10,000 stop all threads and print out the number.
Good luck!
Comments:
Anonymous - 10 years, 1 month ago
C# .Net Solution
reply permalink
Jason Brady - 10 years, 1 month ago
Wouldn't this start each thread and wait for it to end sequentially? Doesn't this defeat the purpose of threaded code?
I think changing this:
to separate loops (or using LINQ) would fix this. It would start all the threads, and then, while they are all running, wait for them to finish.
reply permalink