ThreadDemo.java Source code

Java tutorial

Introduction

Here is the source code for ThreadDemo.java

Source

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();
    }

}