Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

System.exit() closes JVM

 
Robin John
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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..
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's easy: start 2 jvm's and in 1 call System.exit(). See what happens.
 
Robin John
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12085
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

;-)
 
Robin John
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Robin John
Ranch Hand
Posts: 281
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic