Thread pool to control start or threads

Discussion in 'Java' started by sakcee@gmail.com, Apr 27, 2007.

  1. Guest

    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
     
    , Apr 27, 2007
    #1
    1. Advertising

  2. Eric Sosman Guest

    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.

    --
     
    Eric Sosman, Apr 27, 2007
    #2
    1. Advertising

  3. Daniel Pitts Guest

    On Apr 27, 1:11 pm, "" <> 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.
     
    Daniel Pitts, Apr 27, 2007
    #3
  4. Guest

    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 <> wrote:
    > On Apr 27, 1:11 pm, "" <> 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.
     
    , Apr 28, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Enigma Curry
    Replies:
    1
    Views:
    515
    Peter Hansen
    Mar 15, 2006
  2. Replies:
    4
    Views:
    1,251
  3. Ò»Ê×Ê«

    Thread Pool versus Dedicated Threads

    Ò»Ê×Ê«, Aug 14, 2008, in forum: C++
    Replies:
    21
    Views:
    1,116
    gpderetta
    Aug 24, 2008
  4. testisok
    Replies:
    0
    Views:
    326
    testisok
    Feb 17, 2009
  5. Glazner
    Replies:
    0
    Views:
    375
    Glazner
    Jan 6, 2010
Loading...

Share This Page