package j1; //----------------------------------------------------------- public class TestThread { public static void main(String[] args) { System.out.print("TestThread started."); MyThread mt1 = new MyThread("1 ", 1300); MyThread mt2 = new MyThread("2 ", 2900); mt1.start(); mt2.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