@Test public void testFileLock() throws IOException { File file = File.createTempFile("temp", "1"); file.deleteOnExit(); FileLock lock = new FileLock(file); lock.lock(); Assert.assertFalse(lock.tryLock()); lock.unlock(); Assert.assertTrue(lock.tryLock()); lock.unlock(); lock.destroy(); }
public FileLock(File file) throws FileNotFoundException, IOException { this.file = file; file.createNewFile(); channel = new RandomAccessFile(file, "rw").getChannel(); }
FileLock { public FileLock(File file) throws FileNotFoundException, IOException { this.file = file; file.createNewFile(); channel = new RandomAccessFile(file, "rw").getChannel(); } }
FileLock { public FileLock(File file) throws FileNotFoundException, IOException { this.file = file; file.createNewFile(); channel = new RandomAccessFile(file, "rw").getChannel(); } FileLock(File file); }
FileLock { public FileLock(File file) throws FileNotFoundException, IOException { this.file = file; file.createNewFile(); channel = new RandomAccessFile(file, "rw").getChannel(); } FileLock(File file); void lock(); boolean tryLock(); void unlock(); void destroy(); }
FileLock { public FileLock(File file) throws FileNotFoundException, IOException { this.file = file; file.createNewFile(); channel = new RandomAccessFile(file, "rw").getChannel(); } FileLock(File file); void lock(); boolean tryLock(); void unlock(); void destroy();  }