|
PenProfile 2.x | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.livescribe.ext.util.Lock
public class Lock
Implementation of an exclusive lock. This is used by more than one thread to share a resource. The semantics are the same as Java mutexes. In other words, the lock is reentrant. A thread can reacquire the lock any number of times without blocking.
When acquiring a lock, it is a good idea to ensure it is released by putting it in a finally clause.
Note: This uses the current instance for the wait/notify object.
| Constructor Summary | |
|---|---|
Lock()
Creates a new lock object. |
|
| Method Summary | |
|---|---|
void |
acquireLock()
Tries to acquire the lock. |
boolean |
acquireLock(long timeout)
Tries to acquire the lock. |
void |
releaseLock()
Releases the lock if the current thread is the owner. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Lock()
| Method Detail |
|---|
public void acquireLock()
throws InterruptedException
InterruptedException - if this thread has been interrupted.
public boolean acquireLock(long timeout)
throws InterruptedException
As in the behaviour for Object.wait(long), a timeout of zero
indicates that we should wait forever until notified or interrupted.
timeout - the maximum time to wait, in ms
InterruptedException - if this thread was interrupted while
waiting to acquire the lock.
IllegalArgumentException - if the timeout value is negative.public void releaseLock()
|
PenProfile 2.x | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||