ma potrebbe fare una cosa del genere:
//il metodo Posti si trova all'interno della classe principale...quella che gestisce l'arrivo dei thread
static int posti = 100;
synchronized static int Posti(String richiestaCliente){
if (posti<richiestaCliente) try ....wait();
posti = posti - Integer.parseInt(richiestaCliente);
return posti;
notifyall();
}
|