24小时热门版块排行榜    

CyRhmU.jpeg
查看: 427  |  回复: 2

as23p

木虫 (小有名气)

[求助] 这个输出信息中的5和main是什么意思

今天学习多线程基础,代码如下:
class NewThread extends Thread {

NewThread () {
  super("Demo Thread";
  System.out.println("Child thread: " + this) ;
  start();
}

public void run() {
  try {
   for(int i=3; i>0; i--) {
    System.out.println("Child thread: " + i) ;
    Thread.sleep(50);
   }
  } catch(InterruptedException e) {
   System.out.println("Child interrupted." ;
  }
  System.out.println("Exiting child thread." ;
}
}

public class ExtendThread {
public static void main(String[] args) {
  new NewThread();
  try {
   for(int i=3; i>0; i--) {
    System.out.println("Main Thread: " + i) ;
    Thread.sleep(100);
   }
  } catch(InterruptedException e) {
   System.out.println("Main thread interrupted." ;
  }
  System.out.println("Exiting main thread." ;
}
}

得到的输出结果为:
Child thread: Thread[Demo Thread,5,main]
Main Thread: 3
Child thread: 3
Child thread: 2
Main Thread: 2
Child thread: 1
Exiting child thread.
Main Thread: 1
Exiting main thread.

请问,第一行的输出中[Demo Thread,5,main]里的 5 和 main 是什么意思?
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

sj1314

金虫 (著名写手)

继承的父类线程啊,main是主线程的意思

发自小木虫Android客户端
2楼2016-05-23 09:28:23
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

as23p

木虫 (小有名气)

引用回帖:
2楼: Originally posted by sj1314 at 2016-05-23 09:28:23
继承的父类线程啊,main是主线程的意思

(⊙o⊙)哦

“当前回帖不是应助回帖,您不能对此进行金币奖励哦”
请您重新发个应助,我好发金币
3楼2016-05-23 22:17:34
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 as23p 的主题更新
信息提示
请填处理意见