Since all threads run in the same address space, they all have access to the same data and variables. If two threads simultaneously attempt to update a global counter variable, it is possible for their operations to interleave in such way that the global state is not correctly modified. Although such a case may only arise only one time out of thousands, a concurrent program needs to coordinate the activities of multiple threads using something more reliable that just depending on the fact that such interference is rare.
Executor: An object that executes submitted
ExecutorService: A more extensive interface.
ThreadPoolExecutor: Provides an extensible thread pool implementation.
Executors: Provides convenient factory methods for these Executors.
AbstractExecutorService: Provides default implementations of ExecutorService execution methods.
ScheduledExecutorService: An ExecutorService that can schedule commands to run after a given delay, or to execute periodically.
- Shutting Down
Synchronizers (synchronization aids)
- CyclicBarrier循环屏障: A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point.
- CountDownLatch: 当counter为1时为被用作start signal，为N时为complete signal。
Potential threading problems
- Race conditions