notifyexample.java
来自「国外的数据结构与算法分析用书」· Java 代码 · 共 28 行
JAVA
28 行
public class NotifyExample implements Runnable
{
public synchronized void startWaiting()
{
try
{
System.out.println("Thread starting to wait. " + Thread.currentThread());
wait();
System.out.println("Thread just notified to wake up. " + Thread.currentThread());
} catch (InterruptedException e){ }
}
public void run()
{
startWaiting();
}
public synchronized void wakeUpAll()
{
notifyAll();
}
public synchronized void wakeUp()
{
notify();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?