Contents | Package | Class | Tree | Deprecated | Index | Help
PREV | NEXT SHOW LISTS | HIDE LISTS

Class jsync.Mutex

java.lang.Object
    |
    +----jsync.Mutex

public class Mutex
extends java.lang.Object
Class for providing mutual exclusion of threads. Only one thread can enter critical section guarded by mutex (but can do it several times).


Constructor Summary
 Mutex()
 
 

Method Summary
void  enter()
Lock mutex.
boolean  enter(long timeout)
Try to lock mutex within specified period of time.
void  leave()
Release mutex.
 
Methods inherited from class java.lang.Object
 equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Mutex

public Mutex()
Method Detail

enter

public void enter()
Lock mutex. This method should be called before entering critical section.

enter

public boolean enter(long timeout)
Try to lock mutex within specified period of time. This method should be called before entering critical section.
Parameters:
timeout - the maximum time to wait in milliseconds.
Returns:
true if mutex is successfully locked, false if enter() was terminated due to timeout expiration.

leave

public void leave()
Release mutex. This method should be called after exit from critical section. Mutex will be unlocked only if number of leave() invocations is equal to the number of enter() invocations.

Contents | Package | Class | Tree | Deprecated | Index | Help
PREV | NEXT SHOW LISTS | HIDE LISTS