Deadlocks are not fun. A deadlock is a thread related issue. Specifically
when a group of threads are exclusively holding resources, then waiting on
other threads for their resources, in a circle.. hence they will wait
forever. Here is an example:
Say thread A requires resource 1 and 2 to run.
Thread B requires resource 1, 2 and 3 to run.
What happens when thread A starts, get's a hold of resource 1, then thread B
starts, gets a hold of resource 2 and 3, then sits waiting for thread A to
let go of resource 1. Similarly, thread A will now wait for thread B to
finish with resource 2. Thus they are waiting on one another in a
'deadlock' situation because neither will give up the resouce that they just
acquired, but both need to run to completion.
There are ways around this, none are pretty.
1. You can have a 'supervisor' thread that arbitrarily kills one of the
waiting threads when it detects a deadlock (ugly, but there are many
algorithms in computer science used to determine exactly which thread to
kill).
2. You can modify your source so that resources are not exclusive.
Meaning, multiple threads can work with them at once (ugly).
3. You can modify your threads so that they acquire all the resources they
need in a single atomic statement, i.e. a synchronized statement that only
one thread can go through at once, which will delegate resources which allow
all threads to run to completion. This assumes the threads will then give
up the resources later.
Debugging of such things are very tricky. I'd start with putting trace
statements in all of the resource allocating methods.
Hope this helps.
Matt MacGillivray
Technical Developer
Delfour Corporation
(905) 415-9779 x2021
[EMAIL PROTECTED]
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Adam Cassar
Sent: Tuesday, November 14, 2000 6:55 AM
To: Orion-Interest
Subject: DeadlockException
Does anyone know what the following error means?
11/14/00 10:51 PM Error in bean
com.netregistry.aucom.accounting.BillingAccount: Error in ejbPassivate
com.evermind.server.DeadlockException: Deadlock detected: thread 11 is
waiting for resource entity 1003 held by thread 11
Any ideas on how to track it down?