Java tutorial
class ThreadDemo extends Thread { public void run() { // returns the name of this Thread. System.out.println("Name = " + getName()); } } public class Main { public static void main(String args[]) { Thread t = new Thread(new ThreadDemo(), "java2s.com thread"); // set thread priority t.setPriority(1); // print thread created System.out.println("thread = " + t); // this will call run() function t.start(); } }