I'm currently looking for a way to identify hanging threads in java. Anyone knows whats the best way to do this?
Currently I could think off 2 possible ways to do this:
- Calling a (callback-)method periodically within all methods of the Application. This seems a "bit" complex and unsightly... Moreover I have no control when calling external methods...
- An additional Thread which periodically generates Thread-dumps for all Threads (or maybe just for some which should be monitored - as I know which thread I want to monitor) and analyzes the result ("is the thread still at the same point with locks on the same objects" , ...). This could be a bit dangerous as the Thread may again(!) be at the same point... By the way - Is there an easy way to get the Thread dump within Java 1.4 (I don't want to call an external application). I guess with 1.5 or 1.6 there are methods to easily do this...
I guess non of these two methods is a good solution... So do you know a way to do this?
As I said before: I don't want to use any external applications...