Plz tell me what is the difference between exit(0),exit(1),exit(2)?
Printable View
Plz tell me what is the difference between exit(0),exit(1),exit(2)?
the integer values are just a flag... (depends on you)...
In convention, 0 means the java simple/complex application exits without any again any suspicious/malicious process being done before the java application exits...
a positive value will be thrown after terminating the process when an exception occured before the termination of that process....
an example is like:
trying to access dead Component's instance after calling dispose method, after calling garbage collector and System.runFinalization() and before invoking System.exit(int flag)..
Usually, for me, negative values are being treated as flag for an experiment......
eg. having some experiments on an "under testing" application where the program's behavior should be traced when it terminates, what location of the code it terminates exactly, and for prediction/debugging purposes....
PS. you've posted this thread in an inappropriate forum section...
Each process runing on a system if its terminates nicely it returns a value to the parent process.
By convention the 0 means normal termination, any other value depends on the developer mind.
To terminate a java proces, you have the exit() function the argument is the return value of the proces.
Ferran