<div dir="ltr">its confusing at best.<div><br></div><div><a href="https://docs.oracle.com/javase/8/docs/api/java/nio/channels/FileLock.html">https://docs.oracle.com/javase/8/docs/api/java/nio/channels/FileLock.html</a><br></div><div><br></div><div>><span style="color:rgb(71,71,71);font-family:"DejaVu Serif",Georgia,"Times New Roman",Times,serif;font-size:14px">A shared lock prevents other concurrently-running programs from acquiring an overlapping exclusive lock, but does allow them to acquire overlapping shared locks.</span></div><div><span style="color:rgb(71,71,71);font-family:"DejaVu Serif",Georgia,"Times New Roman",Times,serif;font-size:14px"><br></span></div><div><span style="color:rgb(71,71,71);font-family:"DejaVu Serif",Georgia,"Times New Roman",Times,serif;font-size:14px">></span><span style="color:rgb(71,71,71);font-family:"DejaVu Serif",Georgia,"Times New Roman",Times,serif;font-size:14px">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</span></div><div><span style="color:rgb(71,71,71);font-family:"DejaVu Serif",Georgia,"Times New Roman",Times,serif;font-size:14px"><br></span></div><div><span style="color:rgb(71,71,71);font-family:"DejaVu Serif",Georgia,"Times New Roman",Times,serif;font-size:14px">so it doesn't specify the behavior within same program and across threads and what i am finding (for benefit of anyone who comes across this) is that there is an exception if the same thread tries to lock the channel twice in shared mode (original email) but there is no exception if two different threads within same program try to do it.</span></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 14, 2023 at 3:28 PM Brian Burkhalter <<a href="mailto:brian.burkhalter@oracle.com">brian.burkhalter@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div style="overflow-wrap: break-word;">
A "concurrently running program” means a separate process. You are attempting to acquire two overlapping locks in the
<i>same</i> process.
<div><br>
</div>
<div>Brian<br>
<div><br>
<blockquote type="cite">
<div>On Sep 14, 2023, at 2:21 PM, Siddharth Jain <<a href="mailto:siddhsql@gmail.com" target="_blank">siddhsql@gmail.com</a>> wrote:</div>
<br>
<div><a href="https://docs.oracle.com/javase%2F7%2Fdocs%2Fapi%2F%2F/java/nio/channels/FileLock.html" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://docs.oracle.com/javase%2F7%2Fdocs%2Fapi%2F%2F/java/nio/channels/FileLock.html</a><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div style="font-variant-caps:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<span style="font-family:Helvetica;font-style:normal;font-weight:400;font-size:12.16px;color:rgb(53,56,51)">A file lock is either </span><i style="font-family:Helvetica;font-style:normal;font-weight:400;font-size:12.16px;color:rgb(53,56,51)">exclusive</i><span style="font-family:Helvetica;font-style:normal;font-weight:400;font-size:12.16px;color:rgb(53,56,51)"> or </span><i style="font-family:Helvetica;font-style:normal;font-weight:400;font-size:12.16px;color:rgb(53,56,51)">shared</i><span style="font-family:Helvetica;font-style:normal;font-weight:400;font-size:12.16px;color:rgb(53,56,51)">.
 A shared lock prevents other </span><span style="color:rgb(53,56,51);font-style:normal;font-size:14px"><b>concurrently-running programs</b></span><span style="font-family:Helvetica;font-style:normal;font-weight:400;font-size:12.16px;color:rgb(53,56,51)">
 from acquiring an overlapping exclusive lock,<span> </span><b>but does allow them to acquire overlapping shared locks.</b></span></div>
</div>
</blockquote>
</div>
<br>
</div>
</div>

</blockquote></div>