| Author |
JVM will not exit?
|
Jiafan Zhou
Ranch Hand
Joined: Sep 28, 2005
Posts: 192
|
|
The Java VM *will not exit* if non-Daemon threads are executing
The Java VM will exit if only Daemon threads are executing
I wonder what does the first statement mean where JVM will not exit. Suppose I have some non-Daemon threads currently running in my program, does that mean I can never exit the JVM? This does not make a lot sense to me. What happens if I force the JVM to exit by sending killing signal for example?
|
SCJP, SCJD, SCWCD, SCBCD, SCEA
|
 |
Mike Simmons
Ranch Hand
Joined: Mar 05, 2008
Posts: 2778
|
|
|
Neither statement is true. You can still exit by calling System.exit(), or by sending a kill -9 (in Unix) or equivalent from your OS. Both statements make more sense if we replace "will exit" and "will not exit" with "will exit on its own" and "will not exit on its own", respectively.
|
 |
Jiafan Zhou
Ranch Hand
Joined: Sep 28, 2005
Posts: 192
|
|
Mike Simmons wrote:Neither statement is true. You can still exit by calling System.exit(), or by sending a kill -9 (in Unix) or equivalent from your OS. Both statements make more sense if we replace "will exit" and "will not exit" with "will exit on its own" and "will not exit on its own", respectively.
The Java VM *will not exit on its own* if non-Daemon threads are executing.
The Java VM will exit on its own if only Daemon threads are executing.
This makes sense to me. The original words were taken from some text book which obviously are confusing. Thanks.
|
 |
 |
|
|
subject: JVM will not exit?
|
|
|