A method, apparatus, and computer instructions for executing a handler in
a multi-threaded process handling a number of threads in a manner that
avoids deadlocks. A value equal to the number of threads executing in the
data processing system is set. The value is decremented each time a lock
count for a thread within the number of threads is zero. A thread within
the number of threads is suspended if the thread requests a lock and has
a lock count of zero. A procedure, such as a handler, is executed in
response to all of the threads within the number of threads having no
locks.