826220679@qq.com
5 天以前 352da282b6c21700eb454407b92cabcf169a448e
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
40
41
42
43
44
package home;
 
import javax.swing.SwingUtilities;
 
public class Mains {
    // ¼Ç¼Æô¶¯Ê±¼ä
    private static long startTime;
    
    public static void main(String[] args) {
        // ¼Ç¼Æô¶¯Ê±¼ä
        startTime = System.currentTimeMillis();
        // ¼Ç¼´ò¿ªÈÕÖ¾
        LogUtil.logOpen();
        
        if (SingleInstanceLock.lock()) {
            try {
                // ÔÚʼþµ÷¶ÈÏß³ÌÖд´½¨ºÍÏÔʾGUI
                SwingUtilities.invokeLater(() -> {
                    try {
                        // ´´½¨²¢ÏÔʾÖ÷½çÃæ
                        AOAFollowSystem system = new AOAFollowSystem();
                        system.setVisible(true);
                    } catch (Exception e) {
                        e.printStackTrace();
                        LogUtil.log("Æô¶¯¿ÉÊÓ»¯½çÃæÊ±·¢Éú´íÎó: " + e.getMessage());
                    }
                });
            } finally {
                // Ìí¼Ó¹Ø±Õ¹³×Ó
                Runtime.getRuntime().addShutdownHook(new Thread(() -> {
                    // ¼Ç¼¹Ø±ÕÈÕÖ¾
                    LogUtil.logClose(startTime);
                    // Êͷŵ¥ÊµÀýËø
                    SingleInstanceLock.release();
                }));
            }
        } else {
            // ÏÔʾ³ÌÐòÒÑÔÚÔËÐеľ¯¸æ
            SingleInstanceLock.showAlreadyRunningWarning();
            // Í˳ö³ÌÐò
            System.exit(0);
        }
    }
}