sakcee@gmail.com wrote On 04/27/07 16:11,:
> Hi
>
> I want to create a threadpool, to which I can sumbit all jobs but they
> start concurantly or by given a signal runAll.
> is it possiblt by Executors or ExecuteService etc
One easy way to do this would be to "submit" the jobs
by putting them in some kind of Collection, and just let
them sit there. Then when you want them all to start, you
submit one "StarterGun" job to the thread pool: It just
grabs all the jobs out of your Collection, submits them,
and finishes.
An advantage of this technique is that you can use
the same thread pool for multiple "heats" of different
sets of jobs. Just build another Collection and submit
another StarterGun, and off they go.

Signature
Eric.Sosman@sun.com
On Apr 27, 1:11 pm, "sak...@gmail.com" <sak...@gmail.com> wrote:
> Hi
>
[quoted text clipped - 3 lines]
>
> thanks
Why do you want all the jobs to start concurrently? Why not let them
start as you add them?
It wouldn't be possible if you had more threads than CPU cores
anyway... They start when the CPU schedules them first.
If you need to synchronize a lot of things, look into the
CyclicBarrier class.
sakcee@gmail.com - 28 Apr 2007 15:22 GMT
Thanks for info, I kinda did same as both of above ppl said, created a
collection from which threadpool reads. but before starting all jobs
wait
on cyclic barrier and when barrier trips , all are go.
well my manager wants it written that way. if a job is short enuff it
might finish in its time slice and also with letting them start in a
loop or with submit, there might
be some implicit small sequencing that is introduced. I am sure it
does not matter and submitting inside a loop is fine.
thanks
> On Apr 27, 1:11 pm, "sak...@gmail.com" <sak...@gmail.com> wrote:
>
> > Hi
> > I want to create a threadpool, to which I can sumbit all jobs but they
> > start concurantly or by given a signal runAll.
[quoted text clipped - 10 lines]
> If you need to synchronize a lot of things, look into the
> CyclicBarrier class.