Java tutorial
class ThreadDemo implements Runnable { public void run() { System.out.println("Holds Lock = " + Thread.holdsLock(this)); synchronized (this) { System.out.println("Holds Lock = " + Thread.holdsLock(this)); } } } public class Main { public static void main(String[] args) { Thread th = new Thread(new ThreadDemo()); th.start(); } }