Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe21.iad.POSTED!not-for-mail From: Daniel Pitts User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:15.0) Gecko/20120824 Thunderbird/15.0 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: can't throw References: <19af6b94-7a1e-4491-afb2-79782406f560@googlegroups.com> <2da52903-55b6-4288-8f95-9799a5ce874c@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Lines: 24 Message-ID: X-Complaints-To: abuse@newsrazor.net NNTP-Posting-Date: Wed, 12 Sep 2012 22:10:58 UTC Date: Wed, 12 Sep 2012 15:10:57 -0700 X-Received-Bytes: 2156 Xref: csiph.com comp.lang.java.programmer:18707 On 9/12/12 2:24 PM, Robert Klemme wrote: > there is no point in throwing from Thread.run() > or Runnable.run() other than catastrophic failures (all Errors such as > OOM, all RuntimeExceptions which are really programmer mistakes) because > you cannot customize handling of exceptions thrown from the run() > method: this method is only invoked from class Thread and probably > others in the Java standard library itself. Actually, you can handle exceptions from a Thread. There is the UncaughtExceptionHandler: Though the only valuable use I have ever seen from this is in logging those failures differently than the default output. > Instead, you should be > handling exceptions in run() and terminate the thread gracefully (i.e. > by returning from run()). Agreed. If you need some other code to propagate an Exception, you need to pass that information along. Exceptions are meant to unwind the stack. For most practical purposes a Thread's run() method really has no stack to unwind. Even if you could throw an Exception from it, where would that Exception go? Who's going to deal with it?