// @topic T11761 Multithreading -- wait-notify-interrupt example 01 // @brief class IOThread implements Runnable -- the worker thread package mth; public class IOThread implements Runnable { @Override public void run() { Thread ct = Thread.currentThread(); System.out.println( "\t[" + ct.getName() + "] started" ); try { for(;;) { synchronized( ct ) { // wait for a notification ct.wait(); } // print a message once is awake System.out.println( "\t[" + ct.getName() + "] HELLO !!!" ); } } catch( InterruptedException ex ) { System.out.println( "\t[" + ct.getName() + "] interrupted" ); } System.out.println( "\t[" + ct.getName() + "] finished" ); } }//class IOThread