public class Semaphore extends Object implements SyncInterface
| Constructor and Description |
|---|
Semaphore(int count)
Construct semaphore.
|
| Modifier and Type | Method and Description |
|---|---|
void |
lock()
Lock 1 resource.
|
void |
lock(int n)
Lock n resources.
|
boolean |
tryLock()
Try to lock 1 resource.
|
boolean |
trylock(int n)
Try to lock n resources.
|
void |
unlock()
Unlock 1 resource.
|
void |
unlock(int n)
Unlock n resources
|
public Semaphore(int count)
count - number of resources controlled by this semaphorepublic boolean trylock(int n)
n - number of resourcespublic boolean tryLock()
tryLock in interface SyncInterfacepublic void lock(int n)
throws InterruptedException
n - number of resourcesInterruptedExceptionpublic void lock()
throws InterruptedException
lock in interface SyncInterfaceInterruptedExceptionpublic void unlock(int n)
n - number of resourcespublic void unlock()
unlock in interface SyncInterfaceCopyright © 2014–2016 Tomas Teubner. All rights reserved.