Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Thread pool to control start or threads

Reply
Thread Tools

Thread pool to control start or threads

 
 
sakcee@gmail.com
Guest
Posts: n/a
 
      04-27-2007
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

thanks

 
Reply With Quote
 
 
 
 
Eric Sosman
Guest
Posts: n/a
 
      04-27-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) 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.

--
(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Daniel Pitts
Guest
Posts: n/a
 
      04-27-2007
On Apr 27, 1:11 pm, "(E-Mail Removed)" <(E-Mail Removed)> 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.
> is it possiblt by Executors or ExecuteService etc
>
> 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.

 
Reply With Quote
 
sakcee@gmail.com
Guest
Posts: n/a
 
      04-28-2007

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, 2:12 pm, Daniel Pitts <(E-Mail Removed)> wrote:
> On Apr 27, 1:11 pm, "(E-Mail Removed)" <(E-Mail Removed)> 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.
> > is it possiblt by Executors or ExecuteService etc

>
> > 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
an't start a thread Pool from another thread Glazner Python 0 01-06-2010 08:15 PM
Thread control in thread pool for sending testisok Python 0 02-17-2009 07:34 AM
Thread Pool versus Dedicated Threads һʫ C++ 21 08-24-2008 03:14 PM
Waiting all threads in a fixed thread pool yancheng.cheok@gmail.com Java 4 06-16-2007 01:52 AM
Threads: does Thread.start() atomically set Thread.__started ? Enigma Curry Python 1 03-15-2006 01:54 PM



Advertisments