您的位置:首页 > 其它

线程的睡眠与唤醒

2016-03-14 15:42 176 查看
1.线程的睡眠与唤醒

public static void main(String[] args) {
final Thread li = new Thread(){
@Override
public void run() {
System.out.println("li: sleep Zz....");
try {
Thread.sleep(9999999);
} catch (InterruptedException e) {
e.printStackTrace();      //抛出异常
System.out.println("Ha... Ha...");
}
}
};
li.start();

Thread hung = new Thread(){
public void run() {
for (int i = 0; i < 3; i++) {
System.out.println("li... li.... !!! ");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
li.interrupt();
}
};
hung.start();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  线程的唤醒