📄 waituntilmultithreadexit.java
字号:
package org.freethink.tools.thread;
public class WaitUntilMultiThreadExit {
Object lock = new Object();
int activeCount = 0;
public void waiting() {
try {
synchronized (lock) {
lock.wait();
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public synchronized void notifyWaiterToWait() {
activeCount++;
}
public synchronized void notifyWaiterToRun() {
if (--activeCount == 0) {
synchronized(lock) {
lock.notify();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -