Question: Implement the Barrier Interface, as described below, using JAVA SYNCHRONIZATION A barrier is a thread-synchronization mechanism that allows several threads to run for a period
Implement the Barrier Interface, as described below, using JAVA SYNCHRONIZATION


A barrier is a thread-synchronization mechanism that allows several threads to run for a period and then forces all threads to wait until all have reached a certain point. Once all threads have reached this point (the barrier), they may all continue. An interface for a barrier appears as follows: public interface Barrier * Each thread calls this method when it reaches * the barrier. All threads are released to continue *processing when thelast thread calls this method public void waitForOthersO; *Release all threads from waiting for the barrier *Any future calls to waitForOthers) will not vait until the Barrier is set again with a cal1 *to the constructor. public void freeAll O; The following code segment establishes a barrier and creates 10 Worker threads that will synchronize according to the barrier: public static final int THREAD COUNT-10; Barrier jersey = new Barrier!mp1(THREAD_cOUNT); for (int i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
