Thread Starvation
About
Causes of Starvation
Example of Starvation
1. Due to High-Priority Threads
Problem in the Above Code
2. Due to Synchronized Blocks
Example Without Fair Synchronization
Problem
Preventing Starvation
1. Using Fair Locks (ReentrantLock)
Solution
2. Using Thread.yield()
Solution
3. Using wait() and notify() for Cooperative Scheduling
Solution
Starvation vs Deadlock
Feature
Starvation
Deadlock
Last updated