Below is my Multithreading class:
public class Multithreading extends Thread{
public void run(){
for(int i=1;i<5;i++){
try{
Thread.sleep(500);
}catch(InterruptedException e){
System.out.println(e);
}
System.out.println(i);
}
}
public static void main(String args[])
{
Multithreading t1 = new Multithreading();
Multithreading t2 = new Multithreading();
t1.start();
t2.run();
}
}
And, this the output what I got:
1 1 2 2 3 3 4 4
Could you please explain the output, I mean how this execution of start() and run() is working here.