import java.util.ArrayList; import java.lang.InterruptedException; import java.lang.IllegalMonitorStateException; public class Dispatch { public ArrayList < String > msg; public Dispatch () { msg = new ArrayList < String > (1); boolean ok = true; while (ok) { while (msg.size () != 0) { for (int i = 0; i < 5; i++) { System.out.println (i + " " + msg.get (0)); i++; } msg.remove (0); } try { msg.wait (); } catch (InterruptedException e) { System.out.println ("01 " + e.getMessage ()); } catch (IllegalMonitorStateException e) { System.out.println ("02 " + e.getMessage ()); } } } //Dispatch synchronized public void readMsg (String chaine) { } //addMsg } //class