Deadlocks happen when there are two objects having synchronized blocks and two different threads trying to run the synchronized blocks while each one is holding onto a lock that the other needs.
Well, why can't a scheduler make sure that a
thread won't go to sleep while it enters a synchronized block/method. In other words, why does a scheduler kick a thread away from running state while it is holding a key. Why can't it make sure that the thread releases a lock before it can be kicked out from running state or is put to sleep ?
Could that be a solution to fix potential deadlocks ?
Thanks,
Priti