public class ThreadMethod implements Runnable{
	Thread liLei;
	Thread fire;
	Thread alarm;
	ThreadMethod(){
		liLei = new Thread(this);
	}
	public void run(){
		long time=0;
		while(true){
			if(Thread.currentThread()==liLei){
			    System.out.println("李雷今天太累了，抽着烟睡着了......");
			    try{
			        fire = new Thread(this);
			        fire.start();
			        Thread.sleep(1000*60*60);
		    	}catch(InterruptedException e){
			    	System.out.println("李雷被报警声叫醒了！");
			    	fire.interrupt();
		    	}
		    	return;
			
		    }else if(Thread.currentThread()==fire){
			    if(time==0){
			    	System.out.println("李雷的烟头点燃了地毯，李雷还在睡觉......");
			    	time=2000;
			    	try{
					    Thread.sleep(time);
				    } catch(InterruptedException e){
				        System.out.println("e");
			        }
			    }else if(time>0&&time<3000){
				    System.out.println("地毯着火了，李雷还没醒！！！");
				    time=4000;
				    try{
				    	Thread.sleep(time);
			    	} catch(InterruptedException e){
				        System.out.println("e");
			        } 
			    }else if(time>3000){
			    	System.out.println("火势越来越大......");
			    	alarm = new Thread(this);
			    	alarm.start();
			     	try{
			    		Thread.sleep(time);
			    	} catch(InterruptedException e){
			    	    System.out.println("扑灭了地毯上的火,吸烟真是危险啊！");
			    	    return;
			        }
			    }
			
	    	}else if(Thread.currentThread()==alarm){
		    	System.out.println("报警器被触发啦！");
		    	try{
		    		Thread.sleep(500);
		    	}catch(InterruptedException e){
				    System.out.println("e");
			    } 
		    	liLei.interrupt();
		    	return;
		    }
		}
		
	}
}

class TestMain{
	public static void main(String[] args){
		ThreadMethod method = new ThreadMethod();
		method.liLei.start();
	}
}