paint-brush
Brief introduction to AbstractQueuedSynchronizer by Using a Simple Mutex Exampleby@eric.liu.developer
1,889 reads
1,889 reads

Brief introduction to AbstractQueuedSynchronizer by Using a Simple Mutex Example

by ericliuJune 4th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

AbstractQueuedSynchronizer is a masterpiece <a href="https://hackernoon.com/tagged/java" target="_blank">java</a> class authored by Doug Lea. It is the underlying data structure that provides the <a href="https://hackernoon.com/tagged/acquire" target="_blank">acquire</a>, tryAcquire, release, tryRelease&nbsp;… interface to CountDownLatch, Semaphore, ReentrantLock, and ReadWriteLock. So AbstractQueuedSynchronizer is basically the backbone of java.util.concurrent package.
featured image - Brief introduction to AbstractQueuedSynchronizer by Using a Simple Mutex Example
ericliu HackerNoon profile picture

AbstractQueuedSynchronizer is a masterpiece java class authored by Doug Lea. It is the underlying data structure that provides the acquire, tryAcquire, release, tryRelease … interface to CountDownLatch, Semaphore, ReentrantLock, and ReadWriteLock. So AbstractQueuedSynchronizer is basically the backbone of java.util.concurrent package.

I did a short presentation on AQS and try to explain how the simple acquire and release work, hope you will enjoy it.

Here is the code of the Mutex implemented using AQS:

In this video, I explained how this class works and the underlying mechanisms in AQS.