public static void main(String[] args) {
ThreadGroup tg=new ThreadGroup();
myrunnable m1 =new myrunnable();
Thread t1 = new Thread(tg,m1, "呵呵");
System.out.println(t1.getThreadGroup().getName());
}
}
class myrunnable implements Runnable{
@Override
public void run() {
for (int i = 0; i < 100; i++) {
System.out.println("我在执行线程中");
}
}
}
编译会报错!说:“Thread t1 = new Thread(tg,m1, "呵呵");”这一行有错误!
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The constructor Thread(ThreadGroup, myrunnable, String) is undefined
我跟视频里的代码一模一样啊!而且把视频里的代码复制进去也报错,是我的JDK版本有问题吗?1.7啊!
彻底晕菜了 |
|