package wanzai; public class Test1 { public static void main(String[] args) { TestThread tt=new TestThread(); tt.start(); Thread tt1=new Thread(new TestThread1()); tt1.start(); } }
package wanzai; public class TestThread extends Thread { public void run() { for(;;) { System.out.println("0000000"); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } } }
package wanzai; public class TestThread1 implements Runnable { @Override public void run() { for(;;) { System.out.println("0000000"); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } } }