org.littleshoot.util
Class FileLockUtils

java.lang.Object
  extended by org.littleshoot.util.FileLockUtils

public class FileLockUtils
extends Object

Utility methods for dealing with file locks.


Method Summary
static void callWithLock(File file, LockedFileRunner runner)
          Calls the specified Runnable only when a lock is obtained on the specified file.
static void callWithLock(File file, LockedFileRunner runner, boolean truncate)
          Calls the specified Runnable only when a lock is obtained on the specified file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

callWithLock

public static void callWithLock(File file,
                                LockedFileRunner runner)
Calls the specified Runnable only when a lock is obtained on the specified file.

Parameters:
file - The file to obtain a lock on.
runner - The class to call when we have the lock.

callWithLock

public static void callWithLock(File file,
                                LockedFileRunner runner,
                                boolean truncate)
Calls the specified Runnable only when a lock is obtained on the specified file.

Parameters:
file - The file to obtain a lock on.
runner - The class to call when we have the lock.
truncate - Whether or not to truncate the file when we're done -- useful in some file IPC scenarios.


Copyright © 2011-2013 LittleShoot. All Rights Reserved.