I read that throws keyword can’t be used with run method of threads.I wish to know if its a design fault or is there a genuine reason for not allowing this.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The main reason is that there’s no-one to catch the exception, except for any catch-all handlers you might register with your
Threador the containingThreadGroup.Note that you can still throw a
RuntimeException, which will end up at the aforementioned handler.(The same reasoning can be used for
run()s return value ofvoidby the way.)