Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Thread pool to control start or threads

Thread view: 
sakcee@gmail.com - 27 Apr 2007 21:11 GMT
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
Eric Sosman - 27 Apr 2007 21:23 GMT
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

Daniel Pitts - 27 Apr 2007 22:12 GMT
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.