Here is my guess.
JBoss is muti-threaded. The only thing that System.exti(-1) accomplished is that it killed the thread you were running on and set the program exit code. The other threads are still running. To successfully kill the whole application, you must terminate all of the threads. (Actually, the best way to get JBoss to terminate is to send it the terminate signal.)
I don't think so.
Well, in the javadoc of System.exit(int ), it says that: the method will halt the entire JVM. When the entire JVM is halted, then all threads running in it will be certainly terminated. So your guess is not possible.
Any other advice please.
If I should have to write an application server, I would install a SecurityManager with an overwritten checkExit method, so nobody can halt the system just by calling System.exit() within deployed code ;-)
Read this regarding threads (daemon threads) and the system exit.
But my purpose is to stop JBoss via calling System.exit(), not to prevent others to halt the JVM.
So why don't you call shutdown() on the MBean jboss.system.Server?
Because I must shutdown the JBoss when the my application server's initializaion is not complete.
So far I don't know any other way to stop JBoss except calling System.exit().
But now, I will take your advice to try to use shutdown() method in org.jboss.system.Server.
Thanks to all people who have give me a hand.
When use shutdown() in MBean, the JBoss can't really shutdown.
When use exit(int) in MBean, the JBoss will shutdown after deploying all deployment,.
When use halt(int) in MBean, the JBoss immediately shutdown.
Thus, I use halt(int) to shutdown JBoss.
PS, all the three mehod list above is member method of org.jboss.system.server.ServerImplMBean, whose instance make out a JBoss.