public class Reader extends Thread{
...
public static void run()throws InterruptedException{
Monitor mon = new Monitor();
for(int i = 0; i <10; i++)
{
mon.MonEntry();
Read("file.txt");
mon.MonExit();
}
}
}
I cannot use extends Thread for some reason because it says: cannot implement run() in Runnable. I don't see what I did wrong? When we call extends Thread instead of implement Runnable shouldn't we be able to use our own implementation of run() for starting threads?
It is just a public void. No static.
Please, have a look at the documentation. It clearly shows that it is public void :-)
Also, avoid the name Reader because there is a class in java.io package which is named Reader and using names that are already present in Java packages is discouraged :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With