Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: thread pool Date: Tue, 22 Jul 2014 17:14:49 -0400 Organization: A noiseless patient Spider Lines: 29 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 22 Jul 2014 21:14:53 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="bd4e1cba8d8592bec5d5ed9e4537fbfd"; logging-data="14454"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+kPO94yn+alo7Auj5Sk6bU" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: Cancel-Lock: sha1:ii/Rttvk4tew8h1tly6FE10ZXsg= Xref: csiph.com comp.lang.java.programmer:29209 On 7/22/2014 5:01 PM, Philipp Kraus wrote: >[... ugly double-spaced Googlejunk snipped ...] > My solution seems to be similar, but if I run your startThreads again > thet.start(); > > throws the InterruptedException directly, so I do > > main() > { > Master x = new Master(); > > x.startThreads(5); > x.stopThreads(); > x.startThreads(5); <= this does not work because the exception is thrown > } Are you sure startThreads() is creating and starting brand- new Threads each time it's called, not re-using old Threads? To put it another way, are you sure stopThreads() actually stops all the old Threads and waits for them to finish stopping (and then clears its "running workers" list)? I cannot imagine how a newly-created Thread would find itself in the interrupted state before anything interrupts it. Is there some other part of your program that interrupts Threads when it shouldn't? -- esosman@comcast-dot-net.invalid