Ejemplo n.º 1
0
        /// <summary>
        /// Forcibly terminates the currently running Java virtual machine.  This
        /// method never returns normally.
        ///
        /// <para> This method should be used with extreme caution.  Unlike the
        /// <tt><seealso cref="#exit exit"/></tt> method, this method does not cause shutdown
        /// hooks to be started and does not run uninvoked finalizers if
        /// finalization-on-exit has been enabled.  If the shutdown sequence has
        /// already been initiated then this method does not wait for any running
        /// </para>
        /// shutdown hooks or finalizers to finish their work. <para>
        ///
        /// </para>
        /// </summary>
        /// <param name="status">
        ///         Termination status.  By convention, a nonzero status code
        ///         indicates abnormal termination.  If the <tt>{@link Runtime#exit
        ///         exit}</tt> (equivalently, <tt>{@link System#exit(int)
        ///         System.exit}</tt>) method has already been invoked then this
        ///         status code will override the status code passed to that method.
        /// </param>
        /// <exception cref="SecurityException">
        ///         If a security manager is present and its <tt>{@link
        ///         SecurityManager#checkExit checkExit}</tt> method does not permit
        ///         an exit with the specified status
        /// </exception>
        /// <seealso cref= #exit </seealso>
        /// <seealso cref= #addShutdownHook </seealso>
        /// <seealso cref= #removeShutdownHook
        /// @since 1.3 </seealso>
        public virtual void Halt(int status)
        {
            SecurityManager sm = System.SecurityManager;

            if (sm != null)
            {
                sm.CheckExit(status);
            }
            Shutdown.Halt(status);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Terminates the currently running Java virtual machine by initiating its
        /// shutdown sequence.  This method never returns normally.  The argument
        /// serves as a status code; by convention, a nonzero status code indicates
        /// abnormal termination.
        ///
        /// <para> The virtual machine's shutdown sequence consists of two phases.  In
        /// the first phase all registered <seealso cref="#addShutdownHook shutdown hooks"/>,
        /// if any, are started in some unspecified order and allowed to run
        /// concurrently until they finish.  In the second phase all uninvoked
        /// finalizers are run if <seealso cref="#runFinalizersOnExit finalization-on-exit"/>
        /// has been enabled.  Once this is done the virtual machine {@link #halt
        /// halts}.
        ///
        /// </para>
        /// <para> If this method is invoked after the virtual machine has begun its
        /// shutdown sequence then if shutdown hooks are being run this method will
        /// block indefinitely.  If shutdown hooks have already been run and on-exit
        /// finalization has been enabled then this method halts the virtual machine
        /// with the given status code if the status is nonzero; otherwise, it
        /// blocks indefinitely.
        ///
        /// </para>
        /// <para> The <tt><seealso cref="System#exit(int) System.exit"/></tt> method is the
        /// </para>
        /// conventional and convenient means of invoking this method. <para>
        ///
        /// </para>
        /// </summary>
        /// <param name="status">
        ///         Termination status.  By convention, a nonzero status code
        ///         indicates abnormal termination.
        /// </param>
        /// <exception cref="SecurityException">
        ///         If a security manager is present and its <tt>{@link
        ///         SecurityManager#checkExit checkExit}</tt> method does not permit
        ///         exiting with the specified status
        /// </exception>
        /// <seealso cref= java.lang.SecurityException </seealso>
        /// <seealso cref= java.lang.SecurityManager#checkExit(int) </seealso>
        /// <seealso cref= #addShutdownHook </seealso>
        /// <seealso cref= #removeShutdownHook </seealso>
        /// <seealso cref= #runFinalizersOnExit </seealso>
        /// <seealso cref= #halt(int) </seealso>
        public virtual void Exit(int status)
        {
            SecurityManager security = System.SecurityManager;

            if (security != null)
            {
                security.CheckExit(status);
            }
            Shutdown.Exit(status);
        }
Ejemplo n.º 3
0
        public static void RunFinalizersOnExit(bool value)
        {
            SecurityManager security = System.SecurityManager;

            if (security != null)
            {
                try
                {
                    security.CheckExit(0);
                }
                catch (SecurityException)
                {
                    throw new SecurityException("runFinalizersOnExit");
                }
            }
            Shutdown.RunFinalizersOnExit = value;
        }