On Sep 11, 2:06 pm, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
On Fri, 11 Sep 2009 00:32:45 -0700 (PDT), The Dude
<matthewtyle...@googlemail.com> wrote, quoted or indirectly quoted
someone who said :
Can anyone tell me if it possible to cancel blocking operations in the
Executor framework or am I going to have to stick with my current
working (but less elegant) solution of providine an explicit cancel
method in my runnable and calling that when I want to stop the thread?
If you just kill a thread without it's co-operation, you are asking
for trouble -- unclosed files, undisposed resources etc.
It is better if you set a flag that your task periodically checks, and
if it see it, shuts down gracefully. It will not die as quickly. It
will not die if it has gone insane.
--
Roedy Green Canadian Mind Productshttp://mindprod.com
"The coolest thing to do with your data will be thought of by someone else."
~ Rufus Pollock (born: 1978 age: 31) in Talk.
Thanks Roedy.
That is what I wanted to do however because I am submitting a Runnable
and cancelling the thread from a Future I have no way to set a
'cancelled' flag. I also cannot guarantee that I can periodically
check any flag including the interrupted status of the thread because
I may be in a blocking operation such as a socket read that may never
complete.
As suggested I am looking at nio non blocking operations however I
would still love to know if there is a solution to this problem.