Attempts to acquire an exclusive lock on this channel's file.
An invocation of this method of the form fc.tryLock()
behaves in exactly the same way as the invocation
fc.tryLock
(0L, Long.MAX_VALUE, false)
null
if the lock could not be acquired
because another program holds an overlapping lock
ClosedChannelException
| If this channel is closed | |
OverlappingFileLockException
| If a lock that overlaps the requested region is already held by this Java virtual machine, or if another thread is already blocked in this method and is attempting to lock an overlapping region | |
IOException
| If some other I/O error occurs |
lock(), lock(long,long,boolean), tryLock(long,long,boolean)
Diagram: FileChannel