P364实战练习第一题

ZuoyeThread类代码:

 1 package zuoye;
 2 
 3 public class ZuoyeThread extends Thread{
 4 
 5     public void run()
 6     {
 7         try {
 8             Thread.sleep(100);
 9         } catch (InterruptedException e) {
10             // TODO Auto-generated catch block
11             e.printStackTrace();
12         }
13         System.out.println("大家好");
14         try {
15             Thread.sleep(100);
16         } catch (InterruptedException e) {
17             // TODO Auto-generated catch block
18             e.printStackTrace();
19         }
20         System.out.println("今天天气不错");
21         try {
22             Thread.sleep(100);
23         } catch (InterruptedException e) {
24             // TODO Auto-generated catch block
25             e.printStackTrace();
26         }
27         System.out.println("所以我决定去旅行");
28     }
29 }
View Code

Test类代码:

 1 package zuoye;
 2 
 3 public class Thread1 {
 4     public static void main(String arg[])
 5     {
 6         ZuoyeThread t=new ZuoyeThread();
 7         t.start();
 8     }
 9 
10 }
View Code

posted on 2016-03-15 16:21  beens  阅读(149)  评论(0编辑  收藏  举报

导航