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
}
}
В настоящее время я поддерживаю 100 пользователей.Если запрос приходит от jsp (клиента) и проходит через этот класс, автоматически ли будет поток (запрос от JSP) wait
и notify
?