nl.knowledgeplaza.util.thread
Class Semaphore
java.lang.Object
nl.knowledgeplaza.util.thread.Semaphore
public class Semaphore
- extends Object
A simple semaphore for multithreading issues.
- Version:
- $Revision: 1.2 $
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SOURCECODE_VERSION
public static final 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(String Name)
- name of the semaphore (default is hashCode)
getName
public 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 © 2011 KnowledgePlaza. All Rights Reserved.