• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

autoterminating service

 
Greenhorn
Posts: 10
Scala Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I need some kind of executor service which is like java logger is:

- doesn't need explicit shutting down
- executes tasks queue and treminates when all other user's threads are terminated.

The thing is I don't understand how to hook this condition - "all other user's threads are terminated". A daemonizing threads in a pool also doesn't help - threads are interrupted immediately on above condition.

Any tricks?
 
Ranch Hand
Posts: 225
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The actions registered by Runtime.addShutdownHook() will be run when System.exit() is called, when there are no no-daemon threads left, or when Control-C or similar is pressed. Is this what you want?
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Andrew:
A daemonizing threads in a pool also doesn't help



Can you explain as to why doesnt it help?
If all the worker threads in a pool are daemons then the pool will automatically shutdown when the user threads die i.e. your threadpool will not hold a JVM shutdown.

Toggling thread.setDaemon(true); to true and false will unhold and hold JVM termination:


[ July 07, 2008: Message edited by: Nitesh Kant ]
 
Andrew Gaydenko
Greenhorn
Posts: 10
Scala Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems like I have resolved the issue. Please, excuse me for cross-foruming (I have created new topic here after some answerless period at SDN) - I have decribed the situation here:

http://forum.java.sun.com/thread.jspa?messageID=10327012

The main conclusion I have got is to not to use java logger for debugging a termination of concurrent app
 
We don't have time for this. We've gotta save the moon! Or check this out:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic