Concurrent Programming 01--concurrenthashmap
Concurrent programming 02--blocking queues and producer-consumer patterns
Concurrent programming 03--latching countdownlatch and fence Cyclicbarrier
Concurrent programming 04--callable and future
Concurrent programming 05--completionservice:executor and Blockingqueue
Concurrent Programming 06--Task cancellation
Concurrent programming 07--interruption of task cancellation
Concurrent programming 08--task cancellation stop thread-based services
Concurrent programming 09--off of task cancellation Executorservice
Concurrent Programming 10--task cancellation "poison pill" object
Concurrent programming 11--Limitations of the shutdownnow of task cancellation and shutdown
Concurrent programming 12--use of the thread pool configuration threadpoolexecutor and Saturation policy
The overall architecture of the concurrent programming 13--thread pool
The principle of concurrent programming 14--thread pool
Two principles of concurrent programming 15--thread pool
Concurrent Programming 16--lock
Concurrent programming 17--using built-in conditional queues for a simple bounded cache
Concurrent programming 18--an explicit Conditon object
In-depth analysis of concurrent programming 19--abstractqueuedsynchronizer
Concurrent programming 20--Atomic variables and non-blocking synchronization mechanisms
Overview
The disadvantage of the 1th part of the lock
2nd part
Reference
The disadvantage of the 1th part of the lock
Java traditionally uses locks to achieve synchronization between threads. Each object has an internal lock (intrinsic lock), and the keyword synchronized implements the mutex of the lock. The Object.wait method actively discards the lock, and Method Object.notify (all) is used to wake the thread in the waiting. Use synchronized to ensure thread synchronization is correct, but it is also easy to cause thread blocking.
Volatile variables are a more lightweight synchronization mechanism than locks, but they only guarantee the visibility of the memory, not the atomic operation. ++i appears to be atomic, but actually takes the current value, increments it by one, and then writes back the update.
Concurrent programming 20--Atomic variables and non-blocking synchronization mechanisms