You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
privatestaticfinalThreadFactoryexecutorThreadFactory = newThreadFactory() {
privateintthreadId = 0; // <-- a field with non-synchronized access@OverridepublicThreadnewThread(Runnabler) {
Threadthread = newThread(r, String.format("TornadoExecutorThread - %d", threadId));
thread.setDaemon(true);
threadId++;
returnthread;
}
};
Field threadId is used from concurrent threads (due to the nature of ThreadFactory and ExecutorService-s that using it). Hence access to this field should be either synchronized or replaced with better atomic type:
privatestaticfinalThreadFactoryexecutorThreadFactory = newThreadFactory() {
privatefinalAtomicLongthreadId = newAtomicLong(0); // <-- a field with non-synchronized access@OverridepublicThreadnewThread(Runnabler) {
Threadthread = newThread(r, String.format("TornadoExecutorThread - %d", threadId.incrementAndGet()));
thread.setDaemon(true);
returnthread;
}
};
The text was updated successfully, but these errors were encountered:
In current code:
Field
threadId
is used from concurrent threads (due to the nature ofThreadFactory
andExecutorService
-s that using it). Hence access to this field should be either synchronized or replaced with better atomic type:The text was updated successfully, but these errors were encountered: