This week's book giveaway is in the Beginning Java forum.
We're giving away four copies of Get Programming with Java (MEAP only) and have Peggy Fisher on-line!
See this thread for details.
Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Thread Please help  RSS feed

Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 4179
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
It's just a flesh wound! Or a tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!