Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #10708 > unrolled thread

System.exit

Started byRoedy Green <see_website@mindprod.com.invalid>
First post2011-12-13 10:48 -0800
Last post2011-12-14 02:09 -0800
Articles 12 — 6 participants

Back to article view | Back to comp.lang.java.programmer


Contents

  System.exit Roedy Green <see_website@mindprod.com.invalid> - 2011-12-13 10:48 -0800
    Re: System.exit Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-13 14:59 -0500
    Re: System.exit Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-12-13 21:48 +0000
      Re: System.exit Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-12-13 14:14 -0800
        Re: System.exit Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-12-14 00:01 +0000
          Re: System.exit markspace <-@.> - 2011-12-13 16:03 -0800
            Re: System.exit Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-12-14 00:13 +0000
      Re: System.exit Roedy Green <see_website@mindprod.com.invalid> - 2011-12-13 16:53 -0800
        Re: System.exit Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-12-13 20:02 -0500
          Re: System.exit Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-12-13 17:51 -0800
          Re: System.exit Roedy Green <see_website@mindprod.com.invalid> - 2011-12-14 09:38 -0800
    Re: System.exit Paul Cager <paul.cager@googlemail.com> - 2011-12-14 02:09 -0800

#10708 — System.exit

FromRoedy Green <see_website@mindprod.com.invalid>
Date2011-12-13 10:48 -0800
SubjectSystem.exit
Message-ID<9d7fe75jrjv74ksjprrmdca7mp8hb0sflh@4ax.com>
The docs say System.exit terminates the current JVM.  But it seems
that when you have other threads executing, they keep on going.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
For me, the appeal of computer programming is that
even though I am quite a klutz,
I can still produce something, in a sense
perfect, because the computer gives me as many
chances as I please to get it right.
 

[toc] | [next] | [standalone]


#10709

FromEric Sosman <esosman@ieee-dot-org.invalid>
Date2011-12-13 14:59 -0500
Message-ID<jc8aqv$tfd$1@dont-email.me>
In reply to#10708
On 12/13/2011 1:48 PM, Roedy Green wrote:
> The docs say System.exit terminates the current JVM.  But it seems
> that when you have other threads executing, they keep on going.

     Evidence?  Better, yet, SSCCE?

-- 
Eric Sosman
esosman@ieee-dot-org.invalid

[toc] | [prev] | [next] | [standalone]


#10712

FromAndreas Leitgeb <avl@gamma.logic.tuwien.ac.at>
Date2011-12-13 21:48 +0000
Message-ID<slrnjefi0u.fvg.avl@gamma.logic.tuwien.ac.at>
In reply to#10708
Roedy Green <see_website@mindprod.com.invalid> wrote:
> The docs say System.exit terminates the current JVM.  But it seems
> that when you have other threads executing, they keep on going.

Are you sure you really do System.exit(), rather than just
returning from the main() method?   In the latter case, all 
those threads *not* marked as daemon threads keep running.

[toc] | [prev] | [next] | [standalone]


#10713

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2011-12-13 14:14 -0800
Message-ID<q7QFq.24384$LO2.19096@newsfe13.iad>
In reply to#10712
On 12/13/11 1:48 PM, Andreas Leitgeb wrote:
> Roedy Green<see_website@mindprod.com.invalid>  wrote:
>> The docs say System.exit terminates the current JVM.  But it seems
>> that when you have other threads executing, they keep on going.
>
> Are you sure you really do System.exit(), rather than just
> returning from the main() method?   In the latter case, all
> those threads *not* marked as daemon threads keep running.
>
I would think even daemon threads would keep running until the last 
non-daemon thread completed.

[toc] | [prev] | [next] | [standalone]


#10714

FromAndreas Leitgeb <avl@gamma.logic.tuwien.ac.at>
Date2011-12-14 00:01 +0000
Message-ID<slrnjefpr3.fvg.avl@gamma.logic.tuwien.ac.at>
In reply to#10713
Daniel Pitts <newsgroup.nospam@virtualinfinity.net> wrote:
> On 12/13/11 1:48 PM, Andreas Leitgeb wrote:
>> Roedy Green<see_website@mindprod.com.invalid>  wrote:
>>> The docs say System.exit terminates the current JVM.  But it seems
>>> that when you have other threads executing, they keep on going.
>> Are you sure you really do System.exit(), rather than just
>> returning from the main() method?   In the latter case, all
>> those threads *not* marked as daemon threads keep running.
> I would think even daemon threads would keep running until the last 
> non-daemon thread completed.

You're right - I had actually intended to write:
  "... keep *the application* running."
Don't know, where those two words went... ;)

[toc] | [prev] | [next] | [standalone]


#10715

Frommarkspace <-@.>
Date2011-12-13 16:03 -0800
Message-ID<jc8p45$mm7$1@dont-email.me>
In reply to#10714
On 12/13/2011 4:01 PM, Andreas Leitgeb wrote:

> Don't know, where those two words went... ;)


Into the ether (net)....

[toc] | [prev] | [next] | [standalone]


#10716

FromAndreas Leitgeb <avl@gamma.logic.tuwien.ac.at>
Date2011-12-14 00:13 +0000
Message-ID<slrnjefqho.fvg.avl@gamma.logic.tuwien.ac.at>
In reply to#10715
markspace <-@> wrote:
> On 12/13/2011 4:01 PM, Andreas Leitgeb wrote:
>> Don't know, where those two words went... ;)
> Into the ether (net)....
If only they did! :)

[toc] | [prev] | [next] | [standalone]


#10717

FromRoedy Green <see_website@mindprod.com.invalid>
Date2011-12-13 16:53 -0800
Message-ID<6ssfe7dm5tnets3pgkvm5l7k5slotcbef2@4ax.com>
In reply to#10712
On 13 Dec 2011 21:48:15 GMT, Andreas Leitgeb
<avl@gamma.logic.tuwien.ac.at> wrote, quoted or indirectly quoted
someone who said :

>
>Are you sure you really do System.exit()
 
I do a real system exit.
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
For me, the appeal of computer programming is that
even though I am quite a klutz,
I can still produce something, in a sense
perfect, because the computer gives me as many
chances as I please to get it right.
 

[toc] | [prev] | [next] | [standalone]


#10718

FromEric Sosman <esosman@ieee-dot-org.invalid>
Date2011-12-13 20:02 -0500
Message-ID<jc8sjn$ccl$1@dont-email.me>
In reply to#10717
On 12/13/2011 7:53 PM, Roedy Green wrote:
> On 13 Dec 2011 21:48:15 GMT, Andreas Leitgeb
> <avl@gamma.logic.tuwien.ac.at>  wrote, quoted or indirectly quoted
> someone who said :
>
>>
>> Are you sure you really do System.exit()
>
> I do a real system exit.

     SSCCE?

-- 
Eric Sosman
esosman@ieee-dot-org.invalid

[toc] | [prev] | [next] | [standalone]


#10719

FromDaniel Pitts <newsgroup.nospam@virtualinfinity.net>
Date2011-12-13 17:51 -0800
Message-ID<yiTFq.18143$2e7.17922@newsfe18.iad>
In reply to#10718
On 12/13/11 5:02 PM, Eric Sosman wrote:
> On 12/13/2011 7:53 PM, Roedy Green wrote:
>> On 13 Dec 2011 21:48:15 GMT, Andreas Leitgeb
>> <avl@gamma.logic.tuwien.ac.at> wrote, quoted or indirectly quoted
>> someone who said :
>>
>>>
>>> Are you sure you really do System.exit()
>>
>> I do a real system exit.
>
> SSCCE?
>
pittsdosx:noisebridge pittsd$ cat ExitTest.java
public class ExitTest {
    public static void main(String...args) throws Exception {
      new Thread(new Runnable() {
         public void run() {
            while(true) {
              System.out.println("In thread!");
              try {
               Thread.sleep(250);
              } catch (Exception e) {
                e.printStackTrace();
              }
           }
        }}).start();

      Thread.sleep(2000);
      System.out.println("Before exit!");
      try {
        System.exit(-1);
      } finally { System.out.println("Finally!"); }
    }
}
pittsdosx:noisebridge pittsd$ javac ExitTest.java
pittsdosx:noisebridge pittsd$ java ExitTest
In thread!
In thread!
In thread!
In thread!
In thread!
In thread!
In thread!
In thread!
Before exit!
In thread!

I see no evidence that the thread continues after System.exit() is 
finished executing.

Granted, I do see a slight delay, probably due to thread scheduling, 
that my log message for the "before exit" isn't the last thing output.

[toc] | [prev] | [next] | [standalone]


#10730

FromRoedy Green <see_website@mindprod.com.invalid>
Date2011-12-14 09:38 -0800
Message-ID<a8nhe7desj7lpqmr7gsjdtfqoeqh2u4vp2@4ax.com>
In reply to#10718
On Tue, 13 Dec 2011 20:02:46 -0500, Eric Sosman
<esosman@ieee-dot-org.invalid> wrote, quoted or indirectly quoted
someone who said :

>On 12/13/2011 7:53 PM, Roedy Green wrote:
>> On 13 Dec 2011 21:48:15 GMT, Andreas Leitgeb
>> <avl@gamma.logic.tuwien.ac.at>  wrote, quoted or indirectly quoted
>> someone who said :
>>
>>>
>>> Are you sure you really do System.exit()
>>
>> I do a real system exit.
>
>     SSCCE?

There no way  I could write an SCCE with a threadpool simple enough
that anyone would read it or be convinced the problem was with
System.exit (or the thread pool manager somehow defanging
System.exit).I am just pointing this out as a warning if you mix
System.exit and threads  you may get some strange behaviour. I am not
asking you to fix anything for me.

If you want to explore it, try adding a System.exit into your own code
managing a web of threads.

-- 
Roedy Green Canadian Mind Products
http://mindprod.com
For me, the appeal of computer programming is that
even though I am quite a klutz,
I can still produce something, in a sense
perfect, because the computer gives me as many
chances as I please to get it right.
 

[toc] | [prev] | [next] | [standalone]


#10725

FromPaul Cager <paul.cager@googlemail.com>
Date2011-12-14 02:09 -0800
Message-ID<89d3560a-1473-4ff8-832e-7733581224aa@j10g2000vbe.googlegroups.com>
In reply to#10708
On Dec 13, 6:48 pm, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
> The docs say System.exit terminates the current JVM.  But it seems
> that when you have other threads executing, they keep on going.

The only time I've seen that happen is with an older version of Java 6
where the NIO "select" system call was blocking. I never investigated
what caused the problem, and I assume it is fixed now.

Is there anything trying to run because of runFinalizersOnExit()?

Any SecurityManager that might be raising an exception when you call
System.exit()?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web