|
common-util | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectlocal.tomas.util.sync.Semaphore
public class Semaphore
A Semaphore is a kind of synchronized counter. It can be used to limit access to a resource to a specific number of clients.
| Constructor Summary | |
|---|---|
Semaphore(int count)
Construct semaphore. |
|
| Method Summary | |
|---|---|
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 |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Semaphore(int count)
count - number of resources controlled by this semaphore| Method Detail |
|---|
public boolean trylock(int n)
n - number of resources
public boolean trylock()
trylock in interface SyncInterface
public void lock(int n)
throws InterruptedException
n - number of resources
InterruptedException
public void lock()
throws InterruptedException
lock in interface SyncInterfaceInterruptedExceptionpublic void unlock(int n)
n - number of resourcespublic void unlock()
unlock in interface SyncInterface
|
common-util | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||