How to throw a checked exception from a java thread?

后端 未结 9 2149
长发绾君心
长发绾君心 2020-11-28 04: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 i

9条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 05:19

    the thread can't throw the exception to any other thread (nor to the main thread). and you cannot make the inherited run() method throw any checked exceptions since you can only throw less than the inherited code, not more.

提交回复
热议问题