Re: thread pool
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. <http://sscce.org/>
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