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();
}
}
}
我無法使用extends Thread,因爲它說:無法在Runnable中實現run()。我不明白我做錯了什麼?當我們調用extends Thread而不是implements時,Runnable不應該能夠使用我們自己的run()來實現啓動線程嗎?無法在Runnable中實現run()
我仍然得到相同的錯誤... – user2824983
應該讀取()是公共靜態的嗎? – user2824983
擺脫'Exception'並看到。 :) –