package j1; //----------------------------------------------------------- public class TestThread{ public static void main(String[] args){ System.out.print("TestThread started."); MyThread mt1 = new MyThread("5 ", 2100); MyThread mt2 = new MyThread("6 ", 500); MyThread mt3 = new MyThread("7 ", 1000); 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