Package no.digipost.concurrent
Class CountDown
- java.lang.Object
-
- no.digipost.concurrent.CountDown
-
- All Implemented Interfaces:
TargetState
public final class CountDown extends Object implements TargetState
A count down implementation ofTargetState, which will count the invocations ofyet()and returntrueafter a given amount of invocations.The implementation is thread-safe in the sense that it is guaranteed that
yet()will returnfalsean exact amount of times, regardless of different threads invokingyet(), before switching to only returntrue.This can often serve for testing purposes where you would like a controlled amount of queries to a
TargetState, before it changes.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface no.digipost.concurrent.TargetState
TargetState.TaskControl
-
-
Field Summary
-
Fields inherited from interface no.digipost.concurrent.TargetState
IMMEDIATELY, NEVER
-
-
Constructor Summary
Constructors Constructor Description CountDown(long count)Create a new count down from the given startcount.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringtoString()booleanyet()Tell if the target state has been reached yet.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface no.digipost.concurrent.TargetState
or, untilThen, untilThen
-
-
-
-
Constructor Detail
-
CountDown
public CountDown(long count)
Create a new count down from the given startcount.- Parameters:
count- the number of invocations whereyet()will indicate the count down is not finished yet, i.e. the number of timesyet()will returnfalse, and switches to only returntrue.
-
-
Method Detail
-
yet
public boolean yet()
Description copied from interface:TargetStateTell if the target state has been reached yet. Once this method returnstrue, it will never returnfalseagain.- Specified by:
yetin interfaceTargetState- Returns:
truewhen the target state has been reached,falseotherwise.
-
-