public class LimitLatch extends Object
Constructor and Description |
---|
LimitLatch(long limit)
Instantiates a LimitLatch object with an initial limit.
|
Modifier and Type | Method and Description |
---|---|
long |
countDown()
Releases a shared latch, making it available for another thread to use.
|
void |
countUpOrAwait()
Acquires a shared latch if one is available or waits for one if no shared
latch is current available.
|
long |
getCount()
Returns the current count for the latch
|
long |
getLimit()
Obtain the current limit.
|
Collection<Thread> |
getQueuedThreads()
Provide access to the list of threads waiting to acquire this limited
shared latch.
|
boolean |
hasQueuedThreads()
Returns
true if there is at least one thread waiting to
acquire the shared lock, otherwise returns false . |
boolean |
releaseAll()
|
void |
reset()
Resets the latch and initializes the shared acquisition counter to zero.
|
void |
setLimit(long limit)
Sets a new limit.
|
public LimitLatch(long limit)
limit
- - maximum number of concurrent acquisitions of this latchpublic long getCount()
public long getLimit()
public void setLimit(long limit)
limit
- The new limitpublic void countUpOrAwait() throws InterruptedException
InterruptedException
- If the current thread is interruptedpublic long countDown()
public boolean releaseAll()
true
if release was donepublic void reset()
releaseAll()
public boolean hasQueuedThreads()
true
if there is at least one thread waiting to
acquire the shared lock, otherwise returns false
.true
if threads are waitingpublic Collection<Thread> getQueuedThreads()
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.