1 package ThreadL;
2
3 class Thread6L implements Runnable{
/* 用throws抛出异常时,如果向主调处抛异常的方法是从父类继承的或是接口实现的,
那么,覆写父类方法或接口方法时,如果父类中的原方法或接口中的原抽象方法没有抛异常,
则子类覆写父类方法或实现接口方法也不能抛异常。*/
4 public void run() /*throws Exception*/{
5 for(int i=0;i<10;i++){
6 System.out.println( Thread.currentThread().getName() + " 第" + (i+1) + "秒");
7 try{
8 Thread.sleep(1000);
9 }catch(Exception e){
10 e.getStackTrace();
11 }
12 }
13 }
14 }
15 public class Thread6 {
16 public static void main(String[] args){
17 Thread th = new Thread(new Thread6L());
18 th.start();
19 }
20 }