Thread queue

Discussion in 'Java' started by bob smith, Feb 26, 2013.

  1. bob smith

    bob smith Guest

    Is there some kind of system in Java where you can put Thread objects on a queue and they get executed in sequence?

    Thanks.
    bob smith, Feb 26, 2013
    #1
    1. Advertising

  2. bob smith

    Eric Sosman Guest

    On 2/26/2013 10:51 AM, bob smith wrote:
    > Is there some kind of system in Java where you can put Thread objects on a queue and they get executed in sequence?


    You could certainly *do* that, daft though it seems. It would
    be more usual to put "work units" on a queue and let "worker threads"
    take them off and execute them. The java.util.concurrent package
    offers various tools for managing concurrent execution -- although
    since you say "in sequence," it's not clear that concurrency would
    be welcome. I guess you could use Executors.newFixedThreadPool(1)
    and submit your tasks to pool's lone worker thread ...

    --
    Eric Sosman
    d
    Eric Sosman, Feb 26, 2013
    #2
    1. Advertising

  3. bob smith

    Arne Vajhøj Guest

    On 2/26/2013 10:51 AM, bob smith wrote:
    > Is there some kind of system in Java where you can put Thread objects on a queue and they get executed in sequence?


    Call them sequentially instead of starting them??

    Arne
    Arne Vajhøj, Feb 27, 2013
    #3
  4. On 26/02/2013 16:51, bob smith allegedly wrote:
    > Is there some kind of system in Java where you can put Thread objects on a queue and they get executed in sequence?
    >
    > Thanks.


    You're confusing things here. Threads are not things that get executed
    (at least not as far as the JVM is concerned). Threads are the things
    that *execute*. *Runnable*s or *Callable*s are the things that get executed.

    Yes, you can certainly put Runnables or Callables in a queue and have
    them be executed sequentially. As mentioned by someone else in this
    thread, the java.util.concurrent package is the place you'll want to look.

    --
    DF.
    Daniele Futtorovic, Feb 27, 2013
    #4
  5. bob smith

    Roedy Green Guest

    On Tue, 26 Feb 2013 07:51:51 -0800 (PST), bob smith
    <> wrote, quoted or indirectly quoted someone
    who said :

    >Is there some kind of system in Java where you can put Thread objects on a queue and they get executed in sequence?


    see http://mindprod.com/jgloss/thread.html

    then buy the book with the three trains on the cover.
    --
    Roedy Green Canadian Mind Products http://mindprod.com
    One thing I love about having a website, is that when I complain about
    something, I only have to do it once. It saves me endless hours of
    grumbling.
    Roedy Green, Feb 28, 2013
    #5
  6. bob smith

    Arne Vajhøj Guest

    On 2/28/2013 2:22 PM, Roedy Green wrote:
    > On Tue, 26 Feb 2013 07:51:51 -0800 (PST), bob smith
    > <> wrote, quoted or indirectly quoted someone
    > who said :
    >> Is there some kind of system in Java where you can put Thread objects on a queue and they get executed in sequence?

    >
    > see http://mindprod.com/jgloss/thread.html
    >
    > then buy the book with the three trains on the cover.


    I don't think they really covers running things sequentially!

    Arne
    Arne Vajhøj, Feb 28, 2013
    #6
    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. Paul L. Du Bois

    Queue.Queue-like class without the busy-wait

    Paul L. Du Bois, Mar 24, 2005, in forum: Python
    Replies:
    29
    Views:
    1,037
    Antoon Pardon
    Apr 4, 2005
  2. Russell Warren

    Is Queue.Queue.queue.clear() thread-safe?

    Russell Warren, Jun 22, 2006, in forum: Python
    Replies:
    4
    Views:
    659
    Russell Warren
    Jun 27, 2006
  3. Kceiw
    Replies:
    3
    Views:
    979
    Jim Langston
    Mar 14, 2006
  4. Gabriel Rossetti
    Replies:
    3
    Views:
    531
    Jerry Hill
    Apr 25, 2008
  5. Kris
    Replies:
    0
    Views:
    461
Loading...

Share This Page