class ThDemo extends Thread { public void run() { int x; for(x=1;x<=10;x++) { try { Thread.sleep(2000); System.out.println(x); } catch(Exception e) { System.out.println(e); } } } } public class Main { public static void main(String args[]) { ThDemo d1=new ThDemo(); d1.start(); d1.resume(); ThDemo1 d2=new ThDemo1(); d2.start(); } }
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10