Saturday, September 17, 2011

What is 'Deadlock' and 'Livelock'?

Deadlock generally occurs when 2 threads try to acquire same shared resource. In this case each thread end up waiting for other to release lock and deadlock occurs. Deadlock is a common problem in multiprocessing where many processes share a specific type of mutually exclusive resource known as a software lock or soft lock. This could be a case when two threads are trying to write to or update record(s) in a database at a time.

A livelock, on the other-hand, occurs when a request for an exclusive lock is repeatedly denied because a series of overlapping shared locks keep interfering. It is an endless loop in program execution. This could be a case when two threads exit allowing each other to write to or update record(s) in a database.

No comments :