Question
i want the program in JAVA General Instructions: In This program you will write a Thread class (can be a Thread subclass or Runnable interface
i want the program in JAVA
General Instructions: In This program you will write a Thread class (can be a Thread subclass or Runnable interface implementer) which will be responsible in fining the number of prime numbers in a given range.
IN this program The threads will call a method called getWork. This method will return an interval over which to count the number of primes. We refer to this bit of work as a bite. The interval should be small enough to allow for good load balancing, but large enough so that threads are not calling the getWork method constantly. The driver should be responsible for reporting the amount of time it takes to complete the whole job, and the total count of primes over the entire work range.
The output of the Program should report much more information (see next page for details)
1. Number of threads
2. Number of primes computed by each thread
3. Time used by each thread
4. Total number of primes
5. Total time used by the driver
6. Number of bites processed by each thread
7. Speedup
In my program, the following sample output is displayed.
I ran the program of an 8-core machine with a range of 3-10,000,000 with 8 threads.
THREAD-1 getting a bite
THREAD-8 getting a bite
THREAD-6 getting a bite
THREAD-4 getting a bite
THREAD-7 getting a bite
. . .
. . .
THREAD-5 getting a bite
THREAD-2 getting a bite
THREAD-3 getting a bite
THREAD-1 getting a bite
THREAD-6 getting a bite
THREAD-4 getting a bite
THREAD-7 getting a bite
The Program Results
-------------------
THREAD-1: PRIMECOUNT: 91121 TIMER: 1.719127 sec TOTAL BITES: 54
THREAD-2: PRIMECOUNT: 73605 TIMER: 1.713799 sec TOTAL BITES: 45
THREAD-3: PRIMECOUNT: 83974 TIMER: 1.714943 sec TOTAL BITES: 51
THREAD-4: PRIMECOUNT: 97170 TIMER: 1.721303 sec TOTAL BITES: 58
THREAD-5: PRIMECOUNT: 74658 TIMER: 1.688700 sec TOTAL BITES: 45
THREAD-6: PRIMECOUNT: 84127 TIMER: 1.719229 sec TOTAL BITES: 51
THREAD-7: PRIMECOUNT: 78419 TIMER: 1.722470 sec TOTAL BITES: 47
THREAD-8: PRIMECOUNT: 81504 TIMER: 1.678458 sec TOTAL BITES: 49
RANGE: 10,000,000 BITE SIZE = 25,000
TOTAL PRIMES: 664,578
TOTAL THREAD TIME: 13.678028 sec
RUNNING TIME: 1.760415 sec
SPEEDUP: 7.77
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started