|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnachos.threads.Lock
public class Lock
A Lock is a synchronization primitive that has two states, busy and free. There are only two operations allowed on a lock:
Also, only the thread that acquired a lock may release it. As with semaphores, the API does not allow you to read the lock state (because the value could change immediately after you read it).
Constructor Summary | |
---|---|
Lock()
Allocate a new lock. |
Method Summary | |
---|---|
void |
acquire()
Atomically acquire this lock. |
boolean |
isHeldByCurrentThread()
Test if the current thread holds this lock. |
void |
release()
Atomically release this lock, allowing other threads to acquire it. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Lock()
Method Detail |
---|
public void acquire()
public void release()
public boolean isHeldByCurrentThread()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |