public static boolean instanceControl() {
boolean flag = false;
try {
RandomAccessFile raf = new RandomAccessFile(new File(
"jzcdService.lck"), "rw");
FileChannel fc = raf.getChannel();
FileLock lock = fc.tryLock();
if (lock == null) {
flag = true;
}
} catch (Exception ex) {
ex.printStackTrace();
}
return flag;
}
if (instanceControl()) {
System.out.println("集中出单影像提取服务已经在运行中,本服务不能启动,自动退出。");
System.exit(0);
}