I was looking for a good practical\real example of Livelock and I came across a blog of “Richard”. He has shown very good examples of livelock, deadlock and starvation. I was more interested to understand livelock example. Here is the link to his blog Richard’s Blog. Few more examples of livelocks can be found here

After reading Richard’s Blog, next question came to my mind, how to prevent the live locks or any other lock and if it happened how application should handle that.

I found this solution given by “Giuseppe Luciano” which shows a way to solve live lock when it happens in application. Here is his solution – A livelock solution. I believe, “Prevention is better than cure, so first developer should try how to avoid the deadlock situation while designing the solution. I read multiple blogs and googled also for finding the techniques to prevent deadlock, everyone was pointing to “order of lock acquisition” but there were 2 blogs who pointed out few more techniques to prevent deadlock and displayed some more situations where deadlock detection may be missed by the developer. These techniques are :

  1. Lock Ordering
  2. Lock Timeout
  3. Deadlock Detection

You can read more about these techniques on Jenkov’s website. Another site explained different scenarios which can cause a deadlock, you can find it on Brian Goetz’s website. It also shows a solution for live lock problem which was discussed in Richard’s Blog.

Tagged on:                     

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>