假设我有以下情况:
synchronized void someMethod() {
...
try {
wait();
}catch(InterruptedException e) {
System.out.println("InterruptedException caught");
}
...
}
和
synchronized void someOtherMethod() {
...
notify();
}
并且Thread访问首先someMethod,进入wait然后someOtherMethod通知它并返回Runnable状态。notify()调用在方法中的位置是否重要?即使我将notify()调用定位在方法内的不同位置,我也注意到行为没有变化。
拨打电话时不应该Thread立即通知notify()吗?