In the code below the compiler suggested me to use Thread.sleep (the static reference ) not this.sleep, why is that?
public class CThreadUsingThread extends Thread{
public void run(){
for (int i = 0; i < 10; i++) {
System.out.println("Thread running:"+i);
try {
// Why Thread.sleep(Math.round(Math.random()*1000)); is preferred?
this.sleep(Math.round(Math.random()*1000));
} catch (InterruptedException e) {
System.err.println("Thread interrupted!");
}
}
}
public static void main(String [] orgs){
CThreadUsingThread thread = new CThreadUsingThread();
thread.start();
}
}