goja-core/src/main/java/goja/core/kits/lang/JVMKit.java
public static void lockFileForOnlyProcess(String lockName) {
        File file = new File(System.getProperty("java.io.tmpdir"), lockName + ".lock");
        try {
            FileOutputStream output = new FileOutputStream(file);
            FileLock fileLock = output.getChannel().tryLock();
            if (fileLock == null) {
                logger.warn("文件:'" + file + "'已经被lock,进程已经启动,系统将退出");
                System.exit(1);
            }

            PrintStream printStream = new PrintStream(output);
            printStream.println(getPid());
            printStream.flush();

            jvmFile.add(fileLock);
            logger.info("成功lock文件:'" + file + "',用以避免程序被多次启动,pid:" + getPid());
        } catch (IOException e) {
            logger.warn("获得文件lock时异常:'" + file + "',系统退出", e);
            System.exit(2);
        }
    }
public static void lockFileForOnlyProcess(String lockName) {
        File file = new File(System.getProperty("java.io.tmpdir"), lockName + ".lock");
        try {
            FileOutputStream output = new FileOutputStream(file);
            FileLock fileLock = output.getChannel().tryLock();
            if (fileLock == null) {
                logger.warn("文件:'" + file + "'已经被lock,进程已经启动,系统将退出");
                System.exit(1);
            }

            PrintStream printStream = new PrintStream(output);
            printStream.println(getPid());
            printStream.flush();

            jvmFile.add(fileLock);
            logger.info("成功lock文件:'" + file + "',用以避免程序被多次启动,pid:" + getPid());
        } catch (IOException e) {
            logger.warn("获得文件lock时异常:'" + file + "',系统退出", e);
            System.exit(2);
        }
    }
锁定一个临时文件，以便实现一台服务器只能启动一个进程

@param lockName 临时文件名称,不要带目录名称