Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: can't throw Date: Tue, 11 Sep 2012 14:28:07 -0700 Organization: A noiseless patient Spider Lines: 23 Message-ID: References: <19af6b94-7a1e-4491-afb2-79782406f560@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 11 Sep 2012 21:28:10 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="61282af8d6595e8d991edb5ac03d6e00"; logging-data="9440"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18HOZeNItBLPq82eH2n8K0BIif3ExHD3Xg=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120824 Thunderbird/15.0 In-Reply-To: <19af6b94-7a1e-4491-afb2-79782406f560@googlegroups.com> Cancel-Lock: sha1:50HF3slwlAaauw4tWDLRWAJDovw= Xref: csiph.com comp.lang.java.programmer:18658 On 9/11/2012 1:16 PM, bob smith wrote: > In particular, I'm subclassing Thread and can't throw an Exception in > the run method. I suspect this is a more general issue though. > I missed "I'm subclassing Thread" earlier. Yes, it is a general issue. In general, use an Executor, and separate the work to do (a "task" or Runnable/Callable) and the Thread. They're two different things, really, and you shouldn't try to combine them or need to subclass Thread at all. Executors seem complicated when you read the docs but really they're very simple to use and provide a lot of capability that would be tough to try to do on your own. Don't over look Executors or ExecutorService mentioned in those docs.