MyThread.java Source code

Java tutorial

Introduction

Here is the source code for MyThread.java

Source

class MyThread extends Thread {

    MyThread() {
        setDaemon(true);
    }

    public void run() {
        boolean d = isDaemon();
        System.out.println("isDaemon = " + d);
    }
}

public class Main {

    public static void main(String[] args) throws Exception {

        Thread thread = new MyThread();
        System.out.println("thread = " + thread.currentThread());
        thread.setDaemon(true);

        // this will call run() method
        thread.start();
    }
}