class Semaphore {
private int count=100;
public Semaphore(int n) {
this.count = n;
}
public synchronized void acquire() {
while(count == 0) {
try {
wait();
} catch (InterruptedException e) {
//keep trying
}
}
count--;
}
public synchronized void release() {
count++;
notify(); //alert a thread that's blocking on this semaphore
}
}
Actualmente apoyo a 100 usuarios. Si una solicitud proviene de jsp (Cliente) y pasa por esta clase, ¿el subproceso (la solicitud de JSP) wait
y notify
automáticamente?Necesita ayuda para entender el hilo esperar y notificar