// Monitor.java public class Monitor { boolean hecho = false; /** * Waits until done is set to true. */ public void espera() { synchronized (this) { while (! hecho) { try { this.wait(); } catch (InterruptedException ie) {} } } } /** * Sets done to true. */ public void finalizado() { synchronized (this) { hecho = true; this.notify(); } } }