Some more optimization in HashedWheelTimer based on the comments of @viktorklang

This commit is contained in:
Norman Maurer 2012-10-17 15:26:54 +02:00
parent 543cb17acd
commit 9c921b050f

View File

@ -280,9 +280,8 @@ public class HashedWheelTimer implements Timer {
TimerTask.class.getSimpleName());
}
if (!workerState.compareAndSet(1, 2)) {
// workerState can be 0 or 2 at this moment - let it always be 2.
workerState.set(2);
if (workerState.getAndSet(2) != 1) {
// workerState can be 0 or 2 at this moment, so just return an empty set
return Collections.emptySet();
}