RandomAccessFile raf
=
new
RandomAccessFile(
new
File(
"
e:/.lock
"
),
"
rw
"
);
FileChannel fc = raf.getChannel();
FileLock fl = fc.tryLock();
try ... {
FileReader fr = new FileReader(new File("e:/.lock"));
int c;
raf.read();
System.out.println("正常終了");
}
catch (Exception e) ... {
System.out.println("異常終了");
raf.close();
System.exit( -1);
}
FileChannel fc = raf.getChannel();
FileLock fl = fc.tryLock();
try ... {
FileReader fr = new FileReader(new File("e:/.lock"));
int c;
raf.read();
System.out.println("正常終了");
}
catch (Exception e) ... {
System.out.println("異常終了");
raf.close();
System.exit( -1);
}