|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.jtds.jdbc.Semaphore
Simple semaphore class used to serialize access requests over the network connection.
Based on the code originally written by Doug Lea. Once JDK 1.5 is the standard this class can be replaced by thejava.util.concurrent.Sempahore
class.
Field Summary | |
protected long |
permits
Current number of available permits. |
Constructor Summary | |
Semaphore(long initialPermits)
Create a Semaphore with the given initial number of permits. |
Method Summary | |
void |
acquire()
Wait until a permit is available, and take one. |
boolean |
attempt(long msecs)
Wait at most msecs millisconds for a permit. |
long |
permits()
Return the current number of available permits. |
void |
release()
Release a permit. |
void |
release(long n)
Release N permits. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected long permits
Constructor Detail |
public Semaphore(long initialPermits)
Method Detail |
public void acquire() throws java.lang.InterruptedException
java.lang.InterruptedException
public boolean attempt(long msecs) throws java.lang.InterruptedException
java.lang.InterruptedException
public void release()
public void release(long n)
release(n)
is equivalent in effect to:
for (int i = 0; i < n; ++i) release();But may be more efficient in some semaphore implementations.
java.lang.IllegalArgumentException
- if n is negativepublic long permits()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |