futureresult.java
来自「java多线程设计模式源代码」· Java 代码 · 共 21 行
JAVA
21 行
package activeobject;
class FutureResult extends Result {
private Result result;
private boolean ready = false;
public synchronized void setResult(Result result) {
this.result = result;
this.ready = true;
notifyAll();
}
public synchronized Object getResultValue() {
while (!ready) {
try {
wait();
} catch (InterruptedException e) {
}
}
return result.getResultValue();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?