ThreadDemo.java Source code

Java tutorial

Introduction

Here is the source code for ThreadDemo.java

Source

import java.util.*;

class ThreadDemo implements Runnable {

    public void run() {

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

public class Main {

    public static void main(String args[]) {

        ThreadDemo trace = new ThreadDemo();
        Thread t = new Thread(trace);

        // this will call run() method
        t.start();

        // returns a map of stack traces
        Map m = Thread.getAllStackTraces();
    }

}