thread-exceptions

How to throw a checked exception from a java thread?

陌路散爱 提交于 2019-11-26 21:44:45
Hey, I'm writing a network application, in which I read packets of some custom binary format. And I'm starting a background thread to wait for incoming data. The problem is, that the compiler doesn't let me to put any code throwing (checked) exceptions into run() . It says: run() in (...).Listener cannot implement run() in java.lang.Runnable; overridden method does not throw java.io.IOException I want the exception to kill the thread, and let it be caught somewhere in the parent thread. Is this possible to achieve or do I have to handle every exception inside the thread? Caveat: this may not