The static method currentThread() from the type Thread shoul

问题描述:

The static method currentThread() from the type Thread should be accessed in a static way
用静态方式存取 怎么操作?
public static void main(String[] args){
Thread worker=new Thread();
String name = worker.currentThread().getName();
System.out.println(name);
}
其中 worker.currentThread() 出现该警告.
1个回答 分类:综合 2014-11-12

问题解答:

我来补答
它指的是currentThread()方法是个静态方法,用静态方式去访问,不是类的实例去调用.
你可以不管它,或者用Thread.currentThread().getName();
 
 
展开全文阅读
剩余:2000