import java.util.Date;
public class NotifyTest {
private String[] flag = new String[]{"true"};
class NotifyThread extends Thread {
public NotifyThread(String name) {
super(name);
System.out.println("NotifyThread 构造函数 "+new Date());
}
public void run() {
System.out.println("NotifyThread 进入run "+new Date());
try {
System.out.println("NotifyThread 开始sleep "+new Date());
sleep(3000);//推迟3秒钟通知
System.out.println("NotifyThread 结束sleep "+new Date());
} catch (InterruptedException e) {
e.printStackTrace();
}
// flag = "false";
// flag.notify();//Exception in thread "n
Java,wait,notify,notifyAll的使用方法
最新推荐文章于 2025-05-15 18:00:00 发布