com.hazelcast.core
public interface ICountDownLatch extends DistributedObject
java.util.concurrent.CountDownLatch
.
ICountDownLatch is a cluster-wide synchronization aid
that allows one or more threads to wait until a set of operations being
performed in other threads completes.
There are a few differences compared to the ICountDownLatch
:
trySetCount(int)
after a countdown
has finished but not during an active count. This allows the same latch instance to be reused.
Modifier and Type | Method and Description |
---|---|
boolean |
await(long timeout,
TimeUnit unit)
Causes the current thread to wait until the latch has counted down to
zero, or an exception is thrown, or the specified waiting time elapses.
|
void |
countDown()
Decrements the count of the latch, releasing all waiting threads if
the count reaches zero.
|
int |
getCount()
Returns the current count.
|
boolean |
trySetCount(int count)
Sets the count to the given value if the current count is zero.
|
destroy, getId, getName, getPartitionKey, getServiceName
boolean await(long timeout, TimeUnit unit) throws InterruptedException
If the current count is zero then this method returns immediately
with the value true
.
If the current count is greater than zero, then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of five things happen:
countDown()
method,
If the count reaches zero, then the method returns with the
value true
.
If the current thread:
InterruptedException
is thrown and the current thread's
interrupted status is cleared.
If the specified waiting time elapses then the value false
is returned. If the time is less than or equal to zero, the method
will not wait at all.
timeout
- the maximum time to waitunit
- the time unit of the timeout
argumenttrue
if the count reached zero, false
if the waiting time elapsed before the count reached zeroInterruptedException
- if the current thread is interruptedIllegalStateException
- if the Hazelcast instance is shutdown while waitingvoid countDown()
null
.
int getCount()
boolean trySetCount(int count)
false
.count
- the number of times countDown()
must be invoked
before threads can pass through await(long, java.util.concurrent.TimeUnit)
true
if the new count was set, false
if the current
count is not zeroIllegalArgumentException
- if count
is negativeCopyright © 2015 Hazelcast, Inc.. All Rights Reserved.