I am a beginner of multi thread programming.
I've been using Concurrent classes in a multi-threaded environment, but suddenly I was curious about using blockingqueue.
I thought Concurrent classes like ConcurrentHashMap use locking.
Recently, I happened to use QUEUE, and I looked at thread-safe queues. So I knew that there were BlockingQueue and linkedConcurrentQueue, and I studied these two queues.
The blockingqueue is thread-safe using locking. This is the typical thread-safe way I was thinking.
Concurrentqueue is processed thread-safe by using an algorithm called CAS. However, I do not know whether the target of this CAS is the queue itself or an element belonging to the queue. Even if multiple threads poll elements in concurrentqueue at the same time, are they polling different elements? Isn't there a case that polls for the same element at a time?
If so, lock-free concurrentqueue looks too good compared to blockingqueue... What is the reason that blockingqueue is still deprecate and alive? (except for take() method)
Are there any articles I would like to study or reference? Thank you!