@ThreadSafe public final class FileBasedLock extends Object implements Lock, Closeable
Modifier and Type | Field and Description |
---|---|
static FileAttribute<?>[] |
NO_FILE_ATTRS |
Modifier and Type | Method and Description |
---|---|
void |
close()
will release lock if owned, will not nothing if not owned.
|
static Set<PosixFilePermission> |
extractPosixPermissions(FileAttribute<?>[] fileAttributes) |
protected void |
finalize() |
static String |
getContextInfo() |
int |
getLocalHoldCount() |
static FileBasedLock |
getLock(File lockFile) |
static FileBasedLock |
getLock(File lockFile,
FileAttribute<?>... fileAttributes)
Returns a FileBasedLock implementation.
|
boolean |
isHeldByCurrentThread() |
void |
lock() |
void |
lockInterruptibly() |
Condition |
newCondition() |
String |
toString() |
boolean |
tryLock() |
boolean |
tryLock(long time,
TimeUnit unit) |
void |
unlock() |
public static final FileAttribute<?>[] NO_FILE_ATTRS
public static Set<PosixFilePermission> extractPosixPermissions(FileAttribute<?>[] fileAttributes)
public static FileBasedLock getLock(File lockFile, FileAttribute<?>... fileAttributes) throws IOException
lockFile
- the file to lock on.IOException
public static FileBasedLock getLock(File lockFile) throws IOException
IOException
public void lockInterruptibly() throws InterruptedException
lockInterruptibly
in interface Lock
InterruptedException
public boolean tryLock(long time, TimeUnit unit) throws InterruptedException
tryLock
in interface Lock
InterruptedException
public Condition newCondition()
newCondition
in interface Lock
@WillClose public void close()
close
in interface Closeable
close
in interface AutoCloseable
protected void finalize() throws Throwable
public static String getContextInfo()
public int getLocalHoldCount()
public boolean isHeldByCurrentThread()
Copyright © 2018 SPF4J. All rights reserved.