Problem of the Day
A new programming or logic puzzle every Mon-Fri

Threaded Primes

Let's build off of yesterday's problem and create another threaded program. Today's objective is to create a program that spawns several prime number checkers. Each prime number checker will generate a random number between 1 and 1,000 then determine if it is prime or not. If a number is prime add it to a shared variable which is initialized at 0. Once that shared variable reaches a prime number greater than 100,000 stop all threads and print out the number.

Good luck!

Permalink: http://problemotd.com/problem/threaded-primes/

Comments:

  • There are currently no comments. You can be first!

Content curated by @MaxBurstein