我正在开发一个 Android 应用程序。
我有两个线程。第一个必须等待第二个。
我在第一个线程 run
方法上有这段代码:
@Override
public void run() {
synchronized (this.secondThread) {
this.secondThread.wait();
}
[...]
}
在我的第二个线程上:
@Override
public void run() {
synchronized (MyClass.myLock) {
try {
// Do something important here
}
catch (Exception ex)
{
// manage exception
return;
}
finally {
// do something...
}
}
synchronized (this) {
this.notify();
}
[...]
}
如您所见,catch 块内有一个返回。
使用此代码,如果第二个线程发生异常,第一个线程会得到通知吗?