Monday 13 February 2017

Introduction to AbstractQueuedSynchronizer in java

For managing multi-threading applications, java follows monitor construct. According to Monitor construct if a thread is executing a critical section while holding mutex (or intrinsic lock) of an object, no other thread can execute this critical section with lock of same object. synchronized method and synchronized block are simple implementation of this technique.Many concepts of Semaphore and latches are implemented in java over this concept. All concurrent classes introduced in java 1.5 like ReentrantLock, ThreadPoolExecutor and many others are based on this technique. There are times when we require either to wait a thread or to start running a thread, based on the state of an object. Thread can sleep/wait/run depending on some conditions. These types of classes are known as state dependent classes.