Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Maybe this helps!</p> <pre><code>public abstract FileLock tryLock(long position, long size, boolean shared) throws IOException </code></pre> <blockquote> <p>Attempts to acquire a lock on the given region of this channel's file.</p> <p>This method does not block. An invocation always returns immediately, either having acquired a lock on the requested region or having failed to do so. If it fails to acquire a lock because an overlapping lock is held by another program then it returns null. If it fails to acquire a lock for any other reason then an appropriate exception is thrown.</p> <p>The region specified by the position and size parameters need not be contained within, or even overlap, the actual underlying file. Lock regions are fixed in size; if a locked region initially contains the end of the file and the file grows beyond the region then the new portion of the file will not be covered by the lock. If a file is expected to grow in size and a lock on the entire file is required then a region starting at zero, and no smaller than the expected maximum size of the file, should be locked. The zero-argument <code>tryLock()</code> method simply locks a region of size <code>Long.MAX_VALUE</code>.</p> <p>Some operating systems do not support shared locks, in which case a request for a shared lock is automatically converted into a request for an exclusive lock. Whether the newly-acquired lock is shared or exclusive may be tested by invoking the resulting lock object's isShared method.</p> <p>File locks are held on behalf of the entire Java virtual machine. They are not suitable for controlling access to a file by multiple threads within the same virtual machine.</p> <p>Parameters: position - The position at which the locked region is to start; must be non-negative size - The size of the locked region; must be non-negative, and the sum position + size must be non-negative shared - true to request a shared lock, false to request an exclusive lock Returns: A lock object representing the newly-acquired lock, or null if the lock could not be acquired because another program holds an overlapping lock Throws: <code>IllegalArgumentException</code> - If the preconditions on the parameters do not hold <code>ClosedChannelException</code> - If this channel is closed <code>OverlappingFileLockException</code> - 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 of the same file <code>IOException</code> - If some other I/O error occurs See Also: <code>lock()</code>, <code>lock(long,long,boolean)</code>, <code>tryLock()</code></p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload