黑马程序员技术交流社区
标题:
我的TreadGroup不可能这么晕菜
[打印本页]
作者:
freshnboy
时间:
2016-3-22 10:36
标题:
我的TreadGroup不可能这么晕菜
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啊!
彻底晕菜了
作者:
freshnboy
时间:
2016-3-22 10:38
可不可以像知乎一样邀请回答啊!
作者:
骓逝
时间:
2016-3-25 10:55
真有有问题,我运行不会错,就是ThreadGroup的构造方法有问题,你查下API,他的构造有两种,括号后面一定要带东西
作者:
骓逝
时间:
2016-3-25 11:00
没有问题,就是ThreadGroup的构造有问题
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2