Top


定義場所(file name)

jdk/src/share/classes/java/lang/Shutdown.java

説明(description)

    /* Invoked by Runtime.exit, which does all the security checks.
     * Also invoked by handlers for system-provided termination events,
     * which should pass a nonzero status code.
     */

名前(function name)

    static void exit(int status) {

本体部(body)

  {- -------------------------------------------
  (1) 
      ---------------------------------------- -}

            boolean runMoreFinalizers = false;
            synchronized (lock) {
                if (status != 0) runFinalizersOnExit = false;
                switch (state) {
                case RUNNING:       /* Initiate shutdown */
                    state = HOOKS;
                    break;
                case HOOKS:         /* Stall and halt */
                    break;
                case FINALIZERS:
                    if (status != 0) {
                        /* Halt immediately on nonzero status */
                        halt(status);
                    } else {
                        /* Compatibility with old behavior:
                         * Run more finalizers and then halt
                         */
                        runMoreFinalizers = runFinalizersOnExit;
                    }
                    break;
                }
            }

  {- -------------------------------------------
  (1) 
      ---------------------------------------- -}

            if (runMoreFinalizers) {
                runAllFinalizers();
                halt(status);
            }

  {- -------------------------------------------
  (1) java.lang.Shutdown.sequence() を呼んで shutdown hook を実行する.
      その後, java.lang.Shutdown.halt() を呼んで終了処理を行う.
      ---------------------------------------- -}

            synchronized (Shutdown.class) {
                /* Synchronize on the class object, causing any other thread
                 * that attempts to initiate shutdown to stall indefinitely
                 */
                sequence();
                halt(status);
            }

This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.