title: Inter-process file locking in java that throws exception
body: <p>I used FileChannel's tryLock method to obtain a lock on a file from two different java applications, (obviously spawned with 2 different PIDs) , and observed that when a lock is not available, trylock returns <strong>null</strong> instead of throwing an exception. </p>
  
  <p>As per the javadocs :-</p>
  
  <p><a href="https://docs.oracle.com/javase/8/docs/api/java/nio/channels/FileChannel.html#tryLock--" rel="nofollow noreferrer">https://docs.oracle.com/javase/8/docs/api/java/nio/channels/FileChannel.html#tryLock--</a></p>
  
  <p>FileChannel's trylock method should throw exception for inter-thread contention, but returns null for inter-process contention. 
  Is there an API where i could get an exception for inter-process contention as well ?</p>
  
  <p>Thanks</p>