package concur; class Worker extends Thread { public void askNextState() { Thread wrk = Thread.currentThread(); synchronized (wrk) { try { System.out.println("-" + wrk.getName()); wrk.wait(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } public void run() { try { super.setName("WORKER"); while (true) { askNextState(); // simule l'execution d'un code lent Thread.sleep(2000); System.out.println("fini"); } } catch (InterruptedException e) { e.printStackTrace(); } } }