Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!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: Wed, 23 Jul 2014 11:41:13 -0400 Organization: A noiseless patient Spider Lines: 38 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 23 Jul 2014 15:41:17 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="bd4e1cba8d8592bec5d5ed9e4537fbfd"; logging-data="30058"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/mOZfdKixthFlITTJcYC41" 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:YcbRc+TVXZsaXPu9pqDf6PxYSKM= Xref: csiph.com comp.lang.java.programmer:29236 On 7/23/2014 9:57 AM, Philipp Kraus wrote: > On 2014-07-23 11:24:24 +0000, Eric Sosman said: > > > On 7/23/2014 2:11 AM, Philipp Kraus wrote: > > [...] > > It seems, that the CountDownLatch does not work as expected. Any idea? > > > Time for an SSCCE, I think. > > > see the link https://github.com/flashpixx/threadtest (working example) The meaning of the first "S" seems to have eluded you ... I'm not going to plow through all that stuff in detail, and (as I wrote earlier) I'm unfamiliar with ThreadGroup. At a glance, though, it looks like you've got bits and pieces of at least two different synchronization schemes, perhaps more, all mixed together: there's a CountDownLatch *and* a CyclicBarrier *and* an AtomicInteger *and* a bunch of synchronized methods *and* the aforementioned ThreadGroup, ... Perhaps you've been trying to achieve parallelism by adding more and more stuff, but it's my experience that going in the opposite direction is more fruitful. An American philosopher urged us to "Simplify, simplify!" -- in an age before computers, yet I find his advice essential to success in parallel computing. One thing I noticed, though I haven't analyzed things carefully enough to be sure: You initialize the CountDownLatch with a count of five, but six different threads call await() on it. Surely that can't be right, can it? -- esosman@comcast-dot-net.invalid