Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Thread queue

Reply
Thread Tools

Thread queue

 
 
bob smith
Guest
Posts: n/a
 
      02-26-2013
Is there some kind of system in Java where you can put Thread objects on a queue and they get executed in sequence?

Thanks.
 
Reply With Quote
 
 
 
 
Eric Sosman
Guest
Posts: n/a
 
      02-26-2013
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
http://www.velocityreviews.com/forums/(E-Mail Removed)d
 
Reply With Quote
 
 
 
 
Arne Vajhøj
Guest
Posts: n/a
 
      02-27-2013
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


 
Reply With Quote
 
Daniele Futtorovic
Guest
Posts: n/a
 
      02-27-2013
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.
 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      02-28-2013
On Tue, 26 Feb 2013 07:51:51 -0800 (PST), bob smith
<(E-Mail Removed)> 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.
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      02-28-2013
On 2/28/2013 2:22 PM, Roedy Green wrote:
> On Tue, 26 Feb 2013 07:51:51 -0800 (PST), bob smith
> <(E-Mail Removed)> 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


 
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
Program blocked in Queue.Queue.get and Queue.Queue.put Kris Python 0 01-04-2012 03:46 PM
why does the following with Queue, q.put('\x02', True) not put itin the queue? Gabriel Rossetti Python 3 04-25-2008 03:41 PM
Is Queue.Queue.queue.clear() thread-safe? Russell Warren Python 4 06-27-2006 03:03 PM
what's the difference between #include "queue.h" and #include "queue.cpp" Kceiw C++ 3 03-14-2006 03:01 AM
Queue.Queue-like class without the busy-wait Paul L. Du Bois Python 29 04-04-2005 01:28 PM



Advertisments