Originally posted by Dan Temple:
Is there a more elegant solution?
We had a religious discussion about that a while ago, not everyone is very pleased with the idea, but if you are looking for ways to interrupt the processing (rather than merely direct it to do something) you can poll using
You can catch the exception at whatever level is appropriate to your code. To interrupt the worker thread, just thread.interrupt() it. If there are many places where you need to poll it makes sense to put the polling code in a method.
Some feel this is an abuse of the interrupt facility and
you should only use interrupt() if you are actually wait()ing or sleep()ing. I feel that it's exactly what the Thread.interrupt() method was conceived for, provided that you really want to interrupt an ongoing operation.
- Peter
[This message has been edited by Peter den Haan (edited November 22, 2001).]