public class CountedSemaphore extends Semaphore
Constructor and Description |
---|
CountedSemaphore(int threadsRunning)
Construct a new semaphore.
|
CountedSemaphore(int threadsRunning,
int threadsWaiting)
Construct a new semaphore.
|
Modifier and Type | Method and Description |
---|---|
static void |
addSemaphore(String id,
CountedSemaphore s)
Add a new semaphore to the semaphore table
|
static CountedSemaphore |
getSemaphore(String id)
Get the semaphore with key 'id' from the semaphore table
|
void |
P()
Enter the critical section.
|
void |
V()
Leave the critical section.
|
acquire, acquire, acquireUninterruptibly, acquireUninterruptibly, availablePermits, drainPermits, getQueuedThreads, getQueueLength, hasQueuedThreads, isFair, reducePermits, release, release, toString, tryAcquire, tryAcquire, tryAcquire, tryAcquire
public CountedSemaphore(int threadsRunning)
threadsRunning
- how many threads can go into the critical section.public CountedSemaphore(int threadsRunning, int threadsWaiting)
threadsRunning
- how many threads can go into the critical section.threadsWaiting
- how many threads may wait.public static CountedSemaphore getSemaphore(String id)
public static void addSemaphore(String id, CountedSemaphore s)
public void P() throws QueueFullException, InterruptedException
QueueFullException
- when waiting queue is full.InterruptedException
public void V()
@enterprise 10.0.39049 Copyright © 2024 FREQUENTIS AG. All Rights Reserved.