We are using Java 1.5. I have a thread which is supposed to run throughout the life cycle of the application. It goes to sleep for sometime, wakes up and then performs certain operations on a resource. Now at the same time when this thread is operating on the resource, another scheduled thread gets spawned for this resource and performs another set of operation.
Now this 2nd thread is able to complete its operations. But the 1st thread is either hung/killed. We are not able to figure out what happened to the first thread.
Is there any way we can prevent the 1st thread from getting killed/hung when the 2nd thread comes up? Is there a way to find on the machine what is the status of the threads on it when it has already reached this strange state?
Offhand I can't guess what the problem is here. Unfortunately this is one of those situations where by the time you have detected that there's a problem the useful diagnostic info has been lost. The best suggestion I can offer right now is: you need to identiry exactly where in your code did the first thread get killed/hung? Try adding some logging statements in between most/all statements in the existing code. When a thread gets killed or hung, you want to be able to look at a log file to see what was the last message from that thread before it died? What was it about to do? This sort of information is very useful when trying to debug problems such as you describe.
What happens if you hit control break (Windows) or Unix equivalent does it give you the thread stack traces, to say where it was hung or if it was dead or does it not function in this scenario ? Never tried it haven't had a hung thread for a while (thank god)
"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5