Semaphore.java |
public class Semaphore { private int valeur; public Semaphore() { valeur = 1; } public synchronized void P() throws InterruptedException { while(valeur == 0) wait(); valeur = 0; } public synchronized void V() { valeur = 1; notify(); } }