- to ensure that resources are always acquired in some well-defined order means realeas the lock finally clause.
- synchronized method should never call a synchronized method.
Live Example :
By synchronizing the methods of the kitchen class, we are essentially preventing more than one cook from
using the kitchen at a time; the purpose of having multiple threads is to allow more than one cook to use the
kitchen.
Deadlock Code :
Here you will get clear picture for Deadlock :
http://www.itec.uni-klu.ac.at/~harald/CSE/Content/deadlock.html