本帖最后由 Stephen_Chow 于 2013-10-30 22:49 编辑
想写一个简单的类,调用Thread的这个构造函数:public Thread(Runnable target)。在使用MyEclipse工具中,想用匿名内部类的方法传入一个Runnable的实现类,
即为:new Runnable(){},然后工具提示:Add unimplements methods;CTR+1.工具自动生成了代码:- package thread.tigao.day1;
- public class Test {
- public static void main(String[] args) {
- new Thread(new Runnable() {
- @Override
- public void run() {//结果这里出现了红叉:The method run() of type new Runnable(){} must override a superclass method
- // TODO Auto-generated method stub
-
- }
- }).start();
- }
- }
复制代码 程序异常信息:- Exception in thread "main" java.lang.Error: Unresolved compilation problem:
- The method run() of type new Runnable(){} must override a superclass method
- at thread.tigao.day1.TraditionalThreadCommunication.main(TraditionalThreadCommunication.java:13)
复制代码 问题如代码中的注释部分,我怎么想都没想明白。明明复写了run方法呀,为什么提示反而说没有呢?有闷死我了,求求了
|