Is it possible to detect if an object is still used in any running threads?
The application I am currently working on is a Monte Carlo simulator. Sometimes simulations crash but it's not always clear for the user whether a simulation has encountered an error or is just taking a long time. Ideally I would like to have a scheduled event that checks all Simulations with status "Running" periodically to make sure they are in fact still running. So in essence I would like to "ask" the server: "Hey server, are you still using object Simulation with nr 1234 in any of your threads?" If not, something went horribly wrong and the Simulation status should be changed to.. well, "Something went horribly wrong". Any suggestions on how to implement this (in Java)? Or am I asking for the impossible? (ps. if impossible in 2.x but possible in 4.x I am still interested in the answer!)