One way to create a thread is to create a new class that extends Thread, and then to create an instance of that class. The extending class must override the run() method, which is the entry point for the new thread. It must also call start() to begin execution of the new thread.
class ExtendingThread extends Thread { String s[]={"Welcome","to","Java","Programming","Language"}; public static void main(String args[]) { ExtendingThread t=new ExtendingThread("Extending Thread Class"); } public ExtendingThread (String n) { super(n); start(); } public void run() { String name=getName(); for(int i=0;i<s.length;i++) { try { sleep(500); } catch(Exception e) { } System.out.println(name+":"+s[i]); } } }