Question: (Programming, 30 points) Write a program that uses n threads, where n = 1..8. These threads increment a shared variable c. The total number of

(Programming, 30 points) Write a program that uses n threads, where n = 1..8. These threads increment a shared variable c. The total number of increment operations are m 1, 200,000. Each thread reads the value of c and increments it m times. Implement the following methods and compare the the total time taken for each of the following methods for n = 1, 2,4 and 8. public class PIncrement { public static int parallelIncrement(int c, int numThreads) { // your implementation goes here } } Submit the plot as part of the assignment. (a) Lamport's Bakery Algorithm. (b) Java's Atomic Integer (with compareAndSet method). (c) Java's synchronized construct (d) Java's Reentrant Lock Hints for part (a): Remember to use Atomic Boolean and Atomic Integer for shared variables to guarantee atomicity. You can only use get() and set() methods in this part
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
