wood burning stoves 2.0*
The moose likes Java in General and the fly likes System.exit() closes JVM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "System.exit() closes JVM" Watch "System.exit() closes JVM" New topic
Author

System.exit() closes JVM

Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

I just want to know if the System.exit() closes all the instances of the JVM that are running or the only instance which invokes "System.exit();"

the docs say -

"Terminates the currently running Java virtual machine by initiating its shutdown sequence."

how does the System.exit() find which jvm instance to close ?


probably the question is simple.. just need a confirmation..


Time is what we want the most, but what we use the worst. -- William Penn
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

It's easy: start 2 jvm's and in 1 call System.exit(). See what happens.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

Wouter Oet wrote: It's easy: start 2 jvm's and in 1 call System.exit(). See what happens.


aah.. common.. Wouter! I knew this was comming.. but what to do if your girlfriend is waiting for you and you want to know the answer

anyways.. I'll try.. Thanks.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11499
    
  16

Robin John wrote:what to do if your girlfriend is waiting for you and you want to know the answer

I certainly wouldn't post it to a messages board and wait possibly hours for someone to reply.

;-)


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

fred rosenberger wrote:
Robin John wrote:what to do if your girlfriend is waiting for you and you want to know the answer

I certainly wouldn't post it to a messages board and wait possibly hours for someone to reply.

;-)


now Fred, I was expecting a no reply or a answer to the above before I left with her... anyways.. another reason was.. start my system where java is installed write a couple of codes and start..

Wouter Oet wrote:
It's easy: start 2 jvm's and in 1 call System.exit(). See what happens.


and yes.. the one who invokes it dies.. the other runs...

Thanks for nothing, both of you !!

but I love you guys and javaranch


James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Based on the responses so far from Robin (or is it John) I am bound to get castigated for this posting.

What a silly question. Apart from the fact that it would take 20 seconds to test by writing two very very simple Java programs and call System.exit() in one of them, why would it make sense for one Java program to be able to call System.exec() and close all other Java programs that are running? If I was using Netbeans, which is written in Java, to develop Java programs and I called System.exit() inside one of my programs I would be a little ****ed off if it closed down Netbeans!


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Robin John
Ranch Hand

Joined: Sep 10, 2008
Posts: 270

James Sabre wrote:....What a silly question. Apart from the fact that it would take 20 seconds to test by writing two very very simple Java programs and call System.exit() in one of them...


20 seconds or even less.. if you are sitting next to your system, having a ide/textpad, jdk installed... as I have already stated before...

James Sabre wrote: Based on the responses so far from Robin (or is it John) I am bound to get castigated for this posting.


some people get castigated often and easily... try this .
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Robin John wrote:
James Sabre wrote:....What a silly question. Apart from the fact that it would take 20 seconds to test by writing two very very simple Java programs and call System.exit() in one of them...


20 seconds or even less.. if you are sitting next to your system, having a ide/textpad, jdk installed... as I have already stated before...


So you interacted with this site using what?


James Sabre wrote: Based on the responses so far from Robin (or is it John) I am bound to get castigated for this posting.


some people get castigated often and easily... try this .


It seems that you need meditation far more than I do. I cool man.

The point of my previous response was to indicate that it was illogical for System.exit() to close down all JVM instances. But hey - it's no skin off my nose if you just want to ignore the obvious and to waste your time asking a question on these forums that can be rapidly answered by simple experimentation.

Bye
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: System.exit() closes JVM