ThreadDemo.java Source code

Java tutorial

Introduction

Here is the source code for ThreadDemo.java

Source

class ThreadDemo extends Thread {

    public void run() {
        System.out.println("This is run() method");
    }

}

public class Main {

    public static void main(String args[]) {
        Thread currThread = Thread.currentThread();
        // thread created
        Thread t = new Thread(new ThreadDemo(), "java2s.com thread");

        System.out.println("current thread = " + currThread);
        System.out.println("thread created = " + t);
        // this will call run() function
        t.start();
    }

}