Java CyclicBarrier await() methodThe await() method of the Java CyclicBarrier class is used to make the current thread waiting until all the parties have invoked await() method on this barrier or the specified waiting time elapses. SyntaxThis method is overloaded in the following ways. Parameterstimeout ? the time to wait for the barrier unit ? the time unit of the timeout parameter ReturnThe arrival index of the current thread. Example 1Test it NowOutput: Number of parties required to trip the barrier = 3 Sum of product and sum = 0 Is the barrier broken? - false Number of parties waiting at the barrier at this point = 0 Sum of product and sum = 36 Barrier reset successful Example 2Test it NowOutput: Number of parties required to trip the barrier = 3 Sum of product and sum = 0 Is the barrier broken? - false Number of parties waiting at the barrier at this point = 0 Sum of product and sum = 36 Barrier reset successful
Next Topicjava CyclicBarrier
|