一个深入理解JAVA传统线程对象创建的例子

来源:互联网 发布:windows查看内存命令 编辑:程序博客网 时间:2024/05/16 13:07

下面代码展示了传统创建线程的2种方式,如果能正确推测出程序的执行结果,说明你对JAVA线程的创建过程和继承有不错的理解。


public class threadTest {

public static void main(String[] args) {
new Thread(
new Runnable(){
public void run() {
System.out.println("Runnable run");
}
}
){
public void run(){
System.out.println("thread run");
}
}.start();


}

}
原创粉丝点击