public class MonitorsTest implements Runnable { private final Object lock = new Object(); private int counter; @Override public void run() { for (int i = 0; i < 1000_000_000; i++) { synchronized (lock) { counter++; } } } public static void main(String[] args) throws InterruptedException { MonitorsTest test = new MonitorsTest(); Monitors.startProfiling(test.lock); Thread[] threads = new Thread[4]; for (int i = 0; i < threads.length; i++) { threads[i] = new Thread(test); threads[i].start(); } for (Thread thread : threads) { thread.join(); } Monitors.stopProfiling(); System.out.println("Total block time = " + Monitors.getBlockTime() + " ns"); System.out.println("Total block count = " + Monitors.getBlockCount()); } }