zsh_root
2025-12-10 8d662de2fd262b3a485f16e197cb4d0ca2a61cdf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package home;
 
import javax.swing.SwingUtilities;
 
public class Mains {
    // 记录启动时间
    private static long startTime;
 
    public static void main(String[] args) {
        // 记录启动时间
        startTime = System.currentTimeMillis();
        // 记录打开日志
        LogUtil.logOpen();
 
            try {
                // 在事件调度线程中创建和显示GUI
                SwingUtilities.invokeLater(() -> {                    
                    try {
                    // 创建并显示主界面
 
                    new MainFrame().setVisible(true);
 
                } catch (Exception e) {
                    e.printStackTrace();
                    LogUtil.log("启动可视化界面时发生错误: " + e.getMessage());
                }
                });
            } finally {
                // 添加关闭钩子
                Runtime.getRuntime().addShutdownHook(new Thread(() -> {
                    // 记录关闭日志
                    LogUtil.logClose(startTime);
                    // 释放单实例锁
                    SingleInstanceLock.release();
                }));
            }
 
    }
}