-
-
-
CENAPAD-MGCO
A seguir: Exclusão Mútua com Semáforos
Acima: Semáforos
Anterior: Semáforos
public class Semaphore {
int value;
public Semaphore(int initialValue){
value = initialValue;
}
public synchronized void P() {
while (value <= 0 ) {
try {
wait();
catch(InterruptedException e){}
}
value--;
}
public synchronized void V() {
p++;
notify();
}
}