【发布时间】:2016-12-13 18:52:43
【问题描述】:
我注意到以下一段代码:
synchronized (this) {
if (executed) throw new IllegalStateException("Already executed.");
executed = true;
没有意义吗?毕竟是同步的,为什么是if (executed) throw new IllegalStateException("Already executed.");?
【问题讨论】:
-
executed的作用域和生命周期是多少?这是这里的一条重要信息。
标签: java multithreading