[concurrency-interest] Termination of daemon threads

Matthias Ernst matthias at mernst.org
Tue Apr 1 06:17:04 EDT 2008


[Never went to the list due to wrong sender address]

On Tue, Apr 1, 2008 at 9:29 AM, Matthias Ernst <ernst.matthias at gmail.com> wrote:
> SwingWorker has to deal with this, too. It doesn't want its threadpool
>  threads to inhibit VM exit, OTOH doesn't want the VM to exit when
>  they're actually doing something! #setDaemon would have been ideal. I
>  think they solved it by using deamon threads for the pool and adding a
>  shutdown hook that calls pool#shutdown&awaitTermination.
>
>  Matthias
>
>
>
>
>  On Tue, Apr 1, 2008 at 8:04 AM, Rémi Forax <forax at univ-mlv.fr> wrote:
>  > Richard Zschech a écrit :
>  >
>  > > Couldn't you go setDaemon(false) / setDaemon(true) around your critical
>  >  > sections?
>  >  >
>  >  setDeamon() can't be called after the thread starts.
>  >  http://download.java.net/jdk7/docs/api/java/lang/Thread.html#setDaemon(boolean)
>  >
>  >  Rémi
>  >
>  >
>  > > >From Richard.
>  >  >
>  >  >
>  >  > -----Original Message-----
>  >  > From: concurrency-interest-bounces at cs.oswego.edu
>  >  > [mailto:concurrency-interest-bounces at cs.oswego.edu] On Behalf Of David
>  >  > Holmes
>  >  > Sent: Tuesday, 1 April 2008 3:12 PM
>  >  > To: jim.andreou at gmail.com; concurrency-interest at cs.oswego.edu
>  >  > Subject: Re: [concurrency-interest] Termination of daemon threads
>  >  >
>  >  > A daemon thread should never do anything critical. Daemon threads just
>  >  > "vanish" when the process is terminated. Though for Sun's VM they are at
>  >  > least brought to a system "safe-point" first - though executing native
>  >  > code
>  >  > is considered being at a "safe-point" ie outside of the VM.
>  >  >
>  >  > It probably could be documented better.
>  >  >
>  >  > David Holmes
>  >  >
>  >  >
>  >  >> -----Original Message-----
>  >  >> From: concurrency-interest-bounces at cs.oswego.edu
>  >  >> [mailto:concurrency-interest-bounces at cs.oswego.edu]On Behalf Of
>  >  >>
>  >  > Dimitris
>  >  >
>  >  >> Andreou
>  >  >> Sent: Tuesday, 1 April 2008 2:02 PM
>  >  >> To: concurrency-interest at cs.oswego.edu
>  >  >> Subject: [concurrency-interest] Termination of daemon threads
>  >  >>
>  >  >>
>  >  >> Hi all,
>  >  >>
>  >  >> Here is my question: How are daemon threads terminated? What if they
>  >  >>
>  >  > are
>  >  >
>  >  >> in the middle of a critical operation, like writing to a file? They
>  >  >>
>  >  > seem
>  >  >
>  >  >> to exit immediately. How could that be safe? Or a daemon thread should
>  >  >> never do anything critical, but always delegate such work to a
>  >  >> non-daemon thread? If any case, shouldn't it be documented in
>  >  >> java.lang.Thread?
>  >  >>
>  >  >> Thanks
>  >  >> Dimitris Andreou
>  >  >>
>  >  >> _______________________________________________
>  >  >> Concurrency-interest mailing list
>  >  >> Concurrency-interest at altair.cs.oswego.edu
>  >  >> http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
>  >  >>
>  >  >>
>  >  >
>  >  > _______________________________________________
>  >  > Concurrency-interest mailing list
>  >  > Concurrency-interest at altair.cs.oswego.edu
>  >  > http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
>  >  >
>  >  > !DSPAM:1,47f1c9bc745732238521400!
>  >  >
>  >  >
>  >  > _______________________________________________
>  >  > Concurrency-interest mailing list
>  >  > Concurrency-interest at altair.cs.oswego.edu
>  >  > http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
>  >  >
>  >
>  >  _______________________________________________
>  >  Concurrency-interest mailing list
>  >  Concurrency-interest at altair.cs.oswego.edu
>  >  http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
>  >
>



More information about the Concurrency-interest mailing list