Java — java.util.concurrent package | Code Factory

Code Factory
1 min readJun 4, 2020

--

Index Page : Link

Donate : Link

WordPress Blog : Link

The problems with the traditional synchronized keyword :

  1. We are not having any flaxibility to try for a lock without waiting.
  2. There is no way to specify maximum waiting time for a thread to get lock. So that thread will wait until getting the lock which may creates performance problems which may cause deadlock.
  3. If a thread release a lock then which waiting thread will get that lock we are not having any control on this.
  4. There is no API to list out all waiting thread for a lock.
  5. Sychronized keyword compulsory we have to use either at method level or within the method and it is not possible to use across multiple methods.
  • To overcome these problems SUN people introduced java.util.concurrent.locks package in 1.5V.
  • It also provides several enhancement to the programmers to provide more control on concurrency.

--

--