Java — java.util.concurrent package | Code Factory
1 min readJun 4, 2020
Index Page : Link
Donate : Link
WordPress Blog : Link
The problems with the traditional synchronized keyword :
- We are not having any flaxibility to try for a lock without waiting.
- 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.
- If a thread release a lock then which waiting thread will get that lock we are not having any control on this.
- There is no API to list out all waiting thread for a lock.
- 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.