General Archives

Where do deadlocks come from?

Deadlocks are one of the most annoying problems that can occur in multi-threaded programming with parts of a program simply stopping work and waiting indefinitely.

At their simplest, deadlocks are caused when one thread of execution, "Thread A", obtains and holds a lock which another thread of execution, "Thread B", requires whilst itself being blocked from obtaining a lock that it requires because "Thread B" already holds it..

Logo competion underway at

I've run two logo competitions at, this one for The Server Framework and this one for JetByte Limited.

Both were a success and resulted in logos that I'm very happy with, so here we go again!

Updated 23 June 2011 - as you can see, we've now got a logo!

Welcome to

Back in September 2005 I wrote a tool to help me find a deadlock in a complex multi-threaded server that I was building for a client. The tool monitored all lock acquisitions that the target program made and could indicate where lock inversions were occurring. Since any of the lock inversions could become a deadlock given the right thread interaction it was an effective deadlock detector which could report on deadlocks before they happened.

Every so often I'd pull out this tool, use it to locate a deadlock, improve it slightly and then get back to my 'real work' of building complex server systems. The tool evolved and each time that I used it to locate a deadlock, in minutes rather than days, I thought to myself that I should package it up as a product and sell it. There were always other things on the list of things to do and so it has taken until 2011 for me to launch and make the tools that I've been working on over the years available to others.

One thing that I've found amazingly useful is the ability to run my deadlock detection tools as part of my pre-release test cycle. The original deadlock detection tool took a long time to process all of the data that it was gathering about the target application's lock usage, but various performance improvements that I've made over the years now mean that I can run these tools to test high performance client/server systems without affecting the performance of the system under test that much. I then split the tool into three, a Lock Inversion Detector which runs very fast but simply tells you if there are any lock inversions detected, and a Lock Inversion Analyser which tells you exactly which lines of code are the cause of your lock inversions and the full featured Lock Explorer which allows you to navigate all of the data that the tools gather and drill down to explore how your code uses its locks.

The Lock Inversion Detector is available for free, if you run it regularly enough you may never get to the point where you need to purchase the Lock Inversion Analyser to locate your potential deadlocks. Lock Explorer is still in development!

About this Archive

This page is an archive of recent entries in the General category.

Tutorial is the next category.

This is where we write about the development of Lock Explorer, a suite of tools for locating lock inversions, finding deadlocks before they happen and investigating lock usage, contention and performance in multi-threaded code.

Find recent content on the main index or look in the archives to find all content.