void fun() {
// some code
synchronized (this) {
if(condition) {
return;
}
// some code
}
// some code
}
这个return调用是从方法返回fun还是从synchronized块中返回?
void fun() {
// some code
synchronized (this) {
if(condition) {
return;
}
// some code
}
// some code
}
这个return调用是从方法返回fun还是从synchronized块中返回?
return块内synchronized将首先释放所持有的监视器(this在您的示例中),然后退出该方法。
return 将退出您的函数。调用 return 总是退出一个函数。除了 try finally 在退出函数之前将执行 finally 块。