Java Phaser awaitAdvanceInterruptibly() MethodThe awaitAdvanceInterruptibly() method is of Phaser class. Using this method, the phase can await the current phaser from the given phaser value. SyntaxParametersPhase: current phaser value ReturnIt returns number of the next arrived phaser. ThrowsInterruptedException - it throws exception if a thread interrupts while it is waiting. Example 1Test it NowOutput: Thread is sleeping Thread-0 arrived Thread-4 arrived Thread-2 arrived Thread-3 arrived Thread-5 arrived Thread-1 arrived Example 2Test it NowOutput: Thread is sleeping Thread-0 arrived Thread-1 arrived Java Phaser awaitAdvanceInterruptibly(int phase, long timeout, TimeUnit unit)The awaitAdvanceInterruptibly() method of Phaser class awaits the phase of this phaser to advance from the given timeout to elapse or the given phase value. SyntaxParametersphase - It is an arrival phase number timeout - waiting time unit - It is a TimeUnit for determining how to interpret the timeout parameter ReturnsIt returns the phase number of next arrival. If it is negative, then returns the arguments ThrowsInterruptedException - It throws an exception if thread interrupted while waitingTimeoutException - It throws an exception if timed out while waiting Example 3Test it NowOutput: Thread is sleeping Thread-0 arrived Thread-4 arrived Thread-2 arrived Thread-3 arrived Thread-5 arrived Thread-1 arrived Example 4Test it NowOutput: Thread is sleeping Thread-0 arrived Thread-1 arrived Next TopicJava Phaser |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India