This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Thread Please help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread Please help" Watch "Thread Please help" New topic
Author

Thread Please help

S Raman
Greenhorn

Joined: Mar 29, 2006
Posts: 16
Hi,

I have Two main threads which collect data and scheduled to do so 1) in every minute 2) in every 10 mts from two source
using Executors.newScheduledThreadPool

Each thread in turn spawns 10 thread using Executors.newFixedThreadPool after the job is completed it keeps on running
after one minute hread one spawns new 10 thread again

I want it to reuse the same 10 threads how to do it or terminate the threads once job is over
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4168
    
  21

If you want to use the same 10 threads, make the ExecutorService with the 10 threads in a scope outside the runnable method of the task being run, then access the Service from inside the scheduled task to schedule the new task.

If you want to make sure the 10 threads in the ExecutorService get shutdown then call service.shutdown() after the 10 tasks are finished being scheduled.


Steve
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread Please help
 
Similar Threads
Taking advantage of multiprocessing in game programming
ScheduleExecutorService and stopping threads
Quartz scheduler stopped in tomcat
Issue in Quartz rescheduling
skipping synchronization on assuption of JAVA atomic primitive assignment.