package cn.itcast.thread;
/*
* 线程调用方式,休眠
* Thread类静态方法
* sleep(毫秒值) 让线程在指定毫秒值内,休眠
* 时间一到,自动醒来继续执行
*/
class ThreadSleep extends Thread{
public void run(){
for(int x = 0 ; x < 3; x++){
//调用方法
try{
Thread.sleep(2000);
}catch(InterruptedException ex){
}
System.out.println("run.."+x);
}
}
}
public class ThreadDemo3 {
public static void main(String[] args) {
new ThreadSleep().start();
}
}
|
|