RosettaCodeData/Task/Mutex/Java/mutex-1.java
2023-07-01 11:58:00 -04: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
}