Javatpoint Logo
Javatpoint Logo

Java CyclicBarrier await() method

The 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.

Syntax

This method is overloaded in the following ways.

Parameters

timeout ? the time to wait for the barrier

unit ? the time unit of the timeout parameter

Return

The arrival index of the current thread.

Example 1

Test it Now

Output:

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 2

Test it Now

Output:

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





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA