You can do a
t.interrupt()
call, which causes anInterruptException
to be thrown fromread
(which internally callscancelRead
).
Thank you, I’ll try that.
BTW, there should also be a try-catch around the whole task function, which catches this exception, as well as others that may be thrown by
connectTCP
orread
, but currently uncaught exceptions will just terminate the task, so in this case that may be okay.
I see.