You can do a
t.interrupt()call, which causes anInterruptExceptionto 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
connectTCPorread, but currently uncaught exceptions will just terminate the task, so in this case that may be okay.
I see.