See More

class A extends Thread //Extending Thread class to create a Thread of class A { public void run() //Overriding the run() method to implement the Thread { for(int i=0; i<=100; i++) { System.out.println("Hi"); } } } class B extends Thread //Extending Thread class to create a Thread of class B { public void run() //Overriding the run() method to implement the Thread { for(int i=0; i<=100; i++) { System.out.println("Hello"); } } } public class Threads{ public static void main(String[] args){ A obj1=new A(); B obj2=new B(); obj1.start(); //Starting the Thread of class A obj2.start(); //Starting the Thread of class B } }