In reference to the code below, the class MyThread inherits from the Thread class its methods yield() and sleep(). The below code does not compile, the IDE hints to use Thread.yield(), while accepting sleep(). Both methods are inherited by MyThread and hence could e invoked directly. Any explanation , please?
class MyThread extends Thread {
public void run() {
System.out.println("Hi");
yield();
try {
sleep(500);
}
catch(Exception v) {
}
}
}
public class JavaYield {
public static void main(String args[]) {
new MyThread().start();
}
}