We cannot call Runnable's run() method directly on thread's object but according to the below program we are doing it without any compilation or Runtime errors. Why is it so?
public class ThreadCheck implements Runnable {
@Override
public void run() {
for (int i=0; i<10; ) {
System.out.println(++i);
}
}
public static void main(String[] args) {
Thread mythread = new Thread(new ThreadCheck());
mythread.run();
mythread.run();
mythread.start();
}
}
Output: 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10