Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #29268
| From | Eric Sosman <esosman@comcast-dot-net.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: thread pool |
| Date | 2014-07-24 08:39 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <lqqupv$ah9$1@dont-email.me> (permalink) |
| References | (5 earlier) <lqnjln$2l6e$1@ariadne.rz.tu-clausthal.de> <lqo61b$dao$1@dont-email.me> <lqof0k$2res$1@ariadne.rz.tu-clausthal.de> <lqol2t$tba$1@dont-email.me> <lqqe64$mq8$1@ariadne.rz.tu-clausthal.de> |
On 7/24/2014 3:55 AM, Philipp Kraus wrote:
> On 2014-07-23 15:41:13 +0000, Eric Sosman said:
>
>> On 7/23/2014 9:57 AM, Philipp Kraus wrote:
>>>[...]
>>> see the link https://github.com/flashpixx/threadtest (working example)
>>
>> 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?
>
> 5 Threads are running (i=0 to i < 5), so the threads are [0..4] = 5 and
> the await ist
> called from outside (another thread). If you increment the number of the
> CountDownLatch
> the system will hang up
"Surely I can't be right, can I?" ;)
I misread your code: The CSimulation calls await() on the
CountDownLatch, but each CWorker calls await() on a CyclicBarrier
(and calls countDown() on the CountDownLatch). So in fact only
one thread, not six (or five) calls await() on the CountDownLatch.
It's still a mystery to me what the CyclicBarrier is for: It
doesn't appear to serve any useful purpose. It will ensure that
each CWorker finishes the current "step" before moving on to the
next, but (for example) it doesn't guarantee that they'll all see
the same value of m_currentstep.
--
esosman@comcast-dot-net.invalid
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
thread pool Philipp Kraus <philipp.kraus@flashpixx.de> - 2014-07-22 15:00 +0200
Re: thread pool Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-22 09:11 -0400
Re: thread pool Philipp Kraus <philipp.kraus@flashpixx.de> - 2014-07-22 16:32 +0200
Re: thread pool Philipp Kraus <philipp.kraus@flashpixx.de> - 2014-07-22 21:38 +0200
Re: thread pool Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-22 16:29 -0400
Re: thread pool Philipp Kraus <philipp.kraus@flashpixx.de> - 2014-07-22 23:01 +0200
Re: thread pool Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-22 17:14 -0400
Re: thread pool Philipp Kraus <philipp.kraus@flashpixx.de> - 2014-07-23 08:11 +0200
Re: thread pool Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-23 07:24 -0400
Re: thread pool Philipp Kraus <philipp.kraus@flashpixx.de> - 2014-07-23 15:57 +0200
Re: thread pool Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-23 11:41 -0400
Re: thread pool Philipp Kraus <philipp.kraus@flashpixx.de> - 2014-07-24 09:55 +0200
Re: thread pool Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-07-24 08:39 -0400
Re: thread pool Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2014-07-24 20:50 -0700
csiph-web