title: Monitoring Locks with Java Flight Recorder and Java Mission Control
body: <h1>What I want to do</h1>
  
  <p>I have a Java program which I am trying to improve. I suspect synchronized blocks within the code to hurt performance but I would like to make sure this is my problem before touching my code. </p>
  
  <h1>How I went on about it</h1>
  
  <p>To check if synchronized blocks are indeed the issue, I recorded the execution of my program on a test server with Flight Recorder, downloaded the created <code>jfr</code> file on my desktop and opened it with Java Mission Control. However the <code>Lock Instances</code> page in <code>Java Application</code> does not show anything. The only clue I get is a message in the Results view which reads: </p>
  
  <blockquote>
    <p>The Java Blocking rule requires event(s) to be available from the following event types: com.oracle.jdk.JavaMonitorEnter</p>
  </blockquote>
  
  <p>I am therefore assuming there must be some kind of option to activate along with the flight recorder but I wasn't able to find it so far. </p>
  
  <h1>My question</h1>
  
  <p>How do you enable events from the <code>com.oracle.jdk.JavaMonitorEnter</code> type to be recorded by the Java Flight Recorder ?<br>
  Or I am missing something else and there is a better way to figure out how much blocking on synchronized blocks is done in a Java program ?</p>
  
  <h1>My environment</h1>
  
  <p>I am using Oracle JDK version 1.8.0_191. The version of Java Mission Control I am using on my desktop is 6.0.0. Finally, the command I use to record my program's execution is the following: </p>
  
  <pre><code>java -XX:+UnlockCommercialFeatures -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints -XX:+FlightRecorder -XX:StartFlightRecording=settings=profile,dumponexit=true,filename=test.jfr -classpath lib/*:src/ &lt;my program with its arguments&gt;
  </code></pre>
  
  <p>I should also add that connecting to the server directly with Java Mission Control is not an option (or is it?) as I am using an ssh rebound to actually connect to it ...</p>