ExecutorService and synchronization
john s murray
posted 5 years ago
In the use case that you posted, using synchronized run() and somethingElse() methods doesn't really make sense. The instances of the TestThreads class are created inside the loop, as part of the execute(...) method. References to those Oblects can't escape the execute method, and so can't really be accessed by multiple Threads. So there is no need to synchronize those Objects the way you did.