Home | History | Annotate | Download | only in opcodes
      1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      2 
      3 <html>
      4 
      5 <head>
      6 <title>monitor-enter</title>
      7 <link rel=stylesheet href="opcode.css">
      8 </head>
      9 
     10 <body>
     11 
     12 <h1>monitor-enter</h1>
     13 
     14 <h2>Purpose</h2>
     15 
     16 <p>
     17 Acquire the monitor for the indicated object.
     18 </p>
     19 
     20 <h2>Details</h2>
     21 
     22 <table class="instruc">
     23 <thead>
     24 <tr>
     25   <th>Op &amp; Format</th>
     26   <th>Mnemonic / Syntax</th>
     27   <th>Arguments</th>
     28 </tr>
     29 </thead>
     30 <tbody>
     31 <tr>
     32   <td>1d 11x</td>
     33   <td>monitor-enter vAA</td>
     34   <td><code>A:</code> reference-bearing register (8 bits)</td>
     35 </tr>
     36 </tbody>
     37 </table>
     38 
     39 <h2>Constraints</h2>
     40 
     41 <ul>
     42   <li>
     43     A must be a valid register index for the current stack frame.
     44   </li>
     45   <li>
     46     Register vA must contain a reference to an object.
     47   </li>
     48 </ul>
     49 
     50 <h2>Behavior</h2>
     51 
     52 <ul>
     53   <li>
     54     An attempt is made for the current thread to acquire the monitor of the
     55     indicated object. Various results are possible:
     56     <ul>
     57       <li>
     58         If the monitor is not owned by any thread at this point, then the
     59         current thread becomes owner of the monitor. The entry count of the
     60         indicated object is set to 1.
     61       </li>
     62       <li>
     63         Otherwise, if the monitor is owned by the same thread that attempts the
     64         acquiration, then the entry count of the indicated object is increased
     65         by 1.
     66       </li>
     67       <li>
     68         Otherwise the monitor is owned by a different thread. The current thread
     69         sleeps until the monitor of the object is released. Once that happens, a
     70         new attempt to acquire the monitor is made, as described here. There is
     71         no guarantee that the second attempt (or any subsequent attempt) will be
     72         successful.
     73       </li>
     74     </ul>
     75   </li>
     76 </ul>
     77 
     78 <h2>Exceptions</h2>
     79 
     80 <ul>
     81   <li>
     82     NullPointerException if vA is null.
     83   </li>
     84   <li>
     85     IllegalMonitorStateException if the entry count exceeds an
     86     (implementation-dependent) upper bound for recursive monitor entries. Note
     87     that it is unlikely this bound is ever hit, since for most implementations
     88     the call stack will overflow before.
     89   </li>
     90 </ul>
     91 
     92 </body>
     93 </html>
     94