RosettaCodeData/Task/Mutex/Java/mutex-1.java
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

10 lines
376 B
Java

import java.util.concurrent.Semaphore;
public class VolatileClass{
public Semaphore mutex = new Semaphore(1); //also a "fair" boolean may be passed which,
//when true, queues requests for the lock
public void needsToBeSynched(){
//...
}
//delegate methods could be added for acquiring and releasing the mutex
}