调用System.exit(0)-Java之后,应用程序继续运行

|| 我正在尝试关闭应用程序中的资源,然后关闭它,紧接着我上一个问题(检测Java应用程序何时关闭)之后,我实现了以下代码,可以完美地执行清理操作。
//Intercept when the application closes
            Runtime.getRuntime().addShutdownHook(new Thread()
            {
                @Override
                public void run()
                {
                    //Reclaim resources from MIDI usage
                    if(_midiInstance.CleanUp())
                    {
                        Logger.Add(\"Closed resources successfully on ShutDown\");
                    }
                    else
                    {
                        Logger.Add(\"Failed to close all resources on ShutDown\");
                    }
                    System.exit(0);
                }
            });
虽然是System.exit(0);仅在没有可见的GUI的情况下,就可以理解并处理该调用,应用程序继续运行。我曾考虑过将System.exit(0)调用放在Thread之外,但是超出了范围,没有其他线程或流在运行。 挂接到ShutDown事件时,我还需要采取其他步骤以确保一切都关闭吗? 感谢您的宝贵时间,我非常感谢。     
已邀请:
阅读完您的其他问题后,您似乎未在窗口上调用dispose()。如果为true,则可以解释造成问题的原因。     
您需要跳过Windows关闭按钮:
            //overriding the windowClosing() method will allow the user to click the close button
    addWindowListener(
            new WindowAdapter()
    {
        public void windowClosing(WindowEvent e)
        {
            System.exit(0);
        }
    });
通过这样做,程序将关闭,而不仅仅是变得不可见。     

要回复问题请先登录注册