Java tutorial
class ThreadDemo implements Runnable { public void run() { // returns the state of this thread Thread.State state = Thread.currentThread().getState(); System.out.println(Thread.currentThread().getName()); System.out.println("state = " + state); } } public class Main { public static void main(String args[]) { Thread t = new Thread(new ThreadDemo()); // this will call run() function t.start(); } }