package lianxi805; public class MyThread extends Thread { @Override public void run() { super.run (); for(int i = 0;i<10;i++){ Thread t = Thread.currentThread (); System.out.println (t.getName ()+" "+i); } } }
package lianxi805; public class TestMyThread { public static void main(String[] args) { MyThread mt = new MyThread (); Thread t1 = new Thread ( mt ); Thread t2 = new Thread ( mt ); t1.start (); t2.start (); } }
情况一
情况二