/* La classe Semaphore. */ public class Semaphore { private int value; public Semaphore(int n) { value = n; } public synchronized void P() { while (value <= 0) { try { wait(); } catch (InterruptedException e) {}; }; value--; } public synchronized void V() { value++; notifyAll(); } }