nl.knowledgeplaza.util.thread
Class Semaphore
java.lang.Object
nl.knowledgeplaza.util.thread.Semaphore
public class Semaphore
- extends java.lang.Object
A simple semaphore for multithreading issues.
- Version:
- $Revision: 1.2 $
|
Field Summary |
static java.lang.String |
SOURCECODE_VERSION
Standard variable for determining version of a class file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SOURCECODE_VERSION
public static final java.lang.String SOURCECODE_VERSION
- Standard variable for determining version of a class file.
- See Also:
- Constant Field Values
Semaphore
public Semaphore(int n)
- Parameters:
n -
Semaphore
public Semaphore(int n,
boolean exitOnStopFlag)
- Parameters:
n - exitOnStopFlag - see ThreadUtils
setName
public void setName(java.lang.String Name)
- name of the semaphore (default is hashCode)
getName
public java.lang.String getName()
acquire
public void acquire()
aquireNonBlocking
public boolean aquireNonBlocking()
- Returns:
- false is the aquire would have blocked, true if an aquire actually occured
release
public void release()
getValue
public int getValue()
- Get the current value, mostly for debugging purposes.
Beware: to not use this to create a check-and-aquire loop, that will create a whole in the logic.
For such a algorithm, use the aquireNonBlocking.
- Returns:
- current value
Copyright © 2010. All Rights Reserved.