Creating a Thread by Extending Thread class
INPUT:-
class MyThread1 extends Thread{
@Override
public void run() {
while(true) {
System.out.println("I am happy");
}
}
}
class MyThread2 extends Thread{
@Override
public void run() {
while(true) {
System.out.println("I am super happy");
}
}
}
public class Mulithreading {
public static void main(String args[]) {
MyThread1 t1 = new MyThread1();
MyThread2 t2 = new MyThread2();
t1.start();
t2.start();
}
}
OUTPUT:-
0 Comments