【发布时间】:2018-01-17 20:23:32
【问题描述】:
我怀疑下面是否是线程安全的,
// is this thread safe, final int MAX_COUNT = 3 ?
if (retryCount.get() < MAX_COUNT) {
// some other code
retryCount.getAndIncrement();
} else {
// reset count & some other code
retryCount.set(0);
}
上面的条件检查线程安全吗?
【问题讨论】:
标签: java multithreading atomicinteger