package j1; //----------------------------------------------------------- public class TestThread{ public static void main(String[] args){ System.out.print("TestThread started."); MyThread mt1 = new MyThread("1 ", 2000); MyThread mt2 = new MyThread("2 ", 4000); MyThread mt3 = new MyThread("3 ", 8000); mt1.start(); mt2.start(); mt3.start(); } }; //----------------------------------------------------------- class MyThread extends Thread { String str; int msec; MyThread(String txt, int ms) { this.str = txt; this.msec = ms; } public void run() { while(true) { try { System.out.print(this.str); sleep(msec); // tミリ秒動作休止 } catch(InterruptedException e) { break; } } // end while } // end of run } // end of class myThread