Specifica della classe Monitor
// OVERVIEW: un Monitor è un oggetto che può contenere un messaggio (stringa) e
// che permette di trasferire una sequenza di messaggi in modo sincrono da un
// thread produttore ad un thread consumatore
synchronized void send (String msg)
// EFFECTS: se this è vuoto, riceve msg e diventa pieno; altrimenti il thread
// viene sospeso finché this non diventa vuoto
synchronized String receive ( )
// EFFECTS: se this è pieno, restituisce l’ultimo messaggio ricevuto e diventa
// vuoto; altrimenti il thread viene sospeso finché this non diventa pieno
synchronized void finemessaggi ( )
// EFFECTS: this chiude la comunicazione con il produttore
// REQUIRES: il thread produttore non può invocare altri metodi dopo questo
synchronized boolean finecomunicazione ( )
// EFFECTS: restituisce true se this è vuoto ed ha chiuso la comunicazione con il