• Post Reply Bookmark Topic Watch Topic
  • New Topic

Best way to shutdown a ScheduledExecutorService  RSS feed

 
Edoardo Pasca
Greenhorn
Posts: 10
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder what is the best way to shutdown a ScheduledExecutorService. In the following code I start a Runnable every second and I want to stop scheduling new tasks after 10 seconds. And I want the app to close nicely and not hang because the service is not shutdown.
So I shutdown() the service from another scheduled task from the same service.



It seems cumbersome to put the shutdown in the scheduled task from the same very service, that is why I am asking whether there are more appropriate ways to do it.

Thanks
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!