public class Thread1 extends Thread{ public void run(){ int i=0; while(i<10){ i++; System.out.println(i); } } public static void main(String[] args){ Thread1 t=new Thread1(); t.start(); } }
public class Thread2 implements Runnable{ @Override public void run() { int i=10; while(i>0){ i--; System.out.println(i); } } public static void main(String[] args){ Thread2 t=new Thread2(); new Thread(t).start(); } }
线程,较难讲透,初学者不易掌握,带过即可。