A process-wide lock that controls access to a certain region in code block.
Julian provides language-level support for using a lock: var lock = new Lock();
sync (lock) {
... ... // critical region guarded by the lock.
}
Parent Class
Type | Name | Signature |
---|---|---|
constructor | Lock | public Lock() |
method | lock | public void lock() |
method | notify | public void notify() |
method | unlock | public void unlock() |
method | wait | public bool wait() |
method | wait | public int wait(int) |
public Lock()
Create a new lock.
public void lock()
Apply the lock from the place where this is called.
If the lock is held by other threads, this method will block until the lock is secured.
public void notify()
Notify all the other threads waiting on the lock. The platform will make an arbitrary decision on who will be holding the lock next.
Throw IllegalStateException if the lock is not owned by the current thread.
public void unlock()
Release the lock. Throw IllegalStateException if the lock is not owned by the current thread.
public bool wait()
Wait until acquiring the lock or getting interrupted.
Returns
public int wait(int milliSec)
Wait until acquiring the lock, timing out, or getting interrupted.
Parameters
Returns