Java Program to create thread by extending Thread class
Program
class ExtendThread extends Thread
{
public void run()
{
System.out.println("Printing from run():\t" + Thread.currentThread().getName());
}
}
public class ThreadExtendsThreadClass
{
public static void main(String[] args)
{
System.out.println("Threads: Extending Thread Class");
System.out.println("Printing from main:\t" + Thread.currentThread().getName());
ExtendThread extThread = new ExtendThread();
extThread.start();
}
}
Output
Threads: Extending Thread Class
Printing from main: main
Printing from run(): Thread-0