提问在注释那里public class MyFile implements Runnable{
public void run()
{
while (true)
{
try{
FileReader fr=new FileReader(new File("a.txt")) ;
String line=fr.readLine(); System.out.println(line);
}catch(IOException err) {
}
Sleep(1000);//这里为什么要用Thread.sleep。这个thread是哪里来的?是从Object继承来的吗?
}
}求大虾解答。
public void run()
{
while (true)
{
try{
FileReader fr=new FileReader(new File("a.txt")) ;
String line=fr.readLine(); System.out.println(line);
}catch(IOException err) {
}
Sleep(1000);//这里为什么要用Thread.sleep。这个thread是哪里来的?是从Object继承来的吗?
}
}求大虾解答。
int nanos)
throws InterruptedException
Causes the currently executing thread to sleep (cease execution) for the specified number of milliseconds plus the specified number of nanoseconds, subject to the precision and accuracy of system timers and schedulers. The thread does not lose ownership of any monitors. 所有类都是Object类,Thread也不例外