Thread Conditions
Wait for a Thread to be in a State
Conditions.isWaiting(Thread thread)
A Condition that allows you to test if a thread is in a waiting state. For example,
1
|
|
Conditions.is(Thread thread, Thread.State state)
A more general purpose Condition
to check that a thread is in a given state. For example,
1
|
|
Conditions.isAlive(Thread thread)
Checks that a thread is alive. A thread is alive if it has been started and has not yet died. For example,
1
|
|
Wait for an Executor to Shutdown
Conditions.shutdown(ExecutorService service)
Checks that a java.util.concurrent.ExecutorService
has been shutdown according to the result of the it's isShutdown
method. This might be useful if you'd like to wait for shutdown. The tempus-fugit ExecutorServiceShutdown
class does just this.
1
|
|
Invert a Condition
Conditions.not(Condition condition)
The NotCondition
will negate the logical result of some other condition. For example, we can change the example above to wait until a thread is not in a waiting state by using the following.
1
|
|