This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Not sure what I/O activities your thread is doing, but does the I/O function have some sort of timeout handling that you can use? That would probably be the best way to handle this (right at the source), if possible.
John Landon
Ranch Hand
Joined: Sep 25, 2008
Posts: 221
posted
0
Koen Aerts wrote:Not sure what I/O activities your thread is doing, but does the I/O function have some sort of timeout handling that you can use? That would probably be the best way to handle this (right at the source), if possible.
Thanks for your input :-) but it's like saying. "if you are getting robbed in the valley maybe you can call 911 instead of giving out your money". If it was the case I wouldn't ask the question.
Koen Aerts wrote:Not sure what I/O activities your thread is doing, but does the I/O function have some sort of timeout handling that you can use? That would probably be the best way to handle this (right at the source), if possible.
Thanks for your input :-) but it's like saying. "if you are getting robbed in the valley maybe you can call 911 instead of giving out your money". If it was the case I wouldn't ask the question.
Sorry, but I don't get the analogy....
Anyway, other options... If your JVM supports Interrupted I/O, then you can interrupt it from another thread, and have the I/O thread deal with the InterruptedIOException. If the intent is to close the I/O channel anyway, you can close the channel from another thread, and have the I/O thread deal with the I/O exception..... otherwise, your only option (that I see at the moment), is to set a flag; then in the future, if / when this I/O thread comes back, it checks the flag, and stops whatever it is doing, to return from the run method. You can't stop the I/O but you can prevent any further unwanted behavior.