public class BoundedSemaphore extends Semaphore
This class follows DbC(tm) methodology
(Wikipedia).
Where possible, contracts are implement with native's Java
assert.
Constructor and Description |
---|
BoundedSemaphore(int maxCount)
Creates a semaphore bounded by a maximum value of maxCount
Precondition:
maxCount > 0 - positive bound
|
BoundedSemaphore(int maxCount,
int initialCount)
Creates a semaphore bounded by a maximum value of maxCount and
starting with value initialCount
Precondition:
maxCount > 0 - positive bound
initialCount >= 0 && initialCount <= maxCount - valid count
|
Modifier and Type | Method and Description |
---|---|
int |
maxCount()
Bound value.
|
void |
release()
Releases the semaphore.
|
await, await, await, broadcast, interruptWaitingThreads, lockIsMine, registerAwaitingThreads, signal, syncronizedLockIsMine
public BoundedSemaphore(int maxCount)
maxCount > 0
- positive boundmaxCount
- bound valuepublic BoundedSemaphore(int maxCount, int initialCount)
maxCount > 0
- positive boundinitialCount >= 0 && initialCount <= maxCount
- valid countmaxCount
- bound valueinitialCount
- initial value