24小时热门版块排行榜    

查看: 459  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 一志愿天大材料与化工(085600)总分338 +4 蔡大美女 2026-03-13 4/200 2026-03-18 22:47 by walc
[考研] 321求调剂 +3 何润采123 2026-03-18 3/150 2026-03-18 21:27 by li123456789.
[考研] 0703化学 305求调剂 +3 FY_yy 2026-03-14 3/150 2026-03-18 19:40 by macy2011
[考研] 286求调剂 +6 lemonzzn 2026-03-16 9/450 2026-03-18 15:31 by vgtyfty
[考研] 311求调剂 +6 26研0 2026-03-15 6/300 2026-03-18 14:43 by haxia
[考研] 085601材料工程专硕求调剂 +6 慕寒mio 2026-03-16 6/300 2026-03-18 14:26 by 007_lilei
[考研] 278求调剂 +5 烟火先于春 2026-03-17 5/250 2026-03-18 08:43 by 星空星月
[考研] 293求调剂 +11 zjl的号 2026-03-16 16/800 2026-03-18 08:10 by zhukairuo
[考博] 26博士申请 +3 1042136743 2026-03-17 3/150 2026-03-17 23:30 by 轻松不少随
[考研] 268求调剂 +8 一定有学上- 2026-03-14 9/450 2026-03-17 17:47 by laoshidan
[考研] 本人考085602 化学工程 专硕 +16 不知道叫什么! 2026-03-15 18/900 2026-03-17 17:05 by ruiyingmiao
[考研] 26考研求调剂 +6 丶宏Sir 2026-03-13 6/300 2026-03-17 16:13 by 醉在风里
[考研] 有没有道铁/土木的想调剂南林,给自己招师弟中~ +3 TqlXswl 2026-03-16 7/350 2026-03-17 15:23 by TqlXswl
[考研] 283求调剂 +3 听风就是雨; 2026-03-16 3/150 2026-03-17 07:41 by 热情沙漠
[考研] 327求调剂 +6 拾光任染 2026-03-15 11/550 2026-03-15 22:47 by 拾光任染
[考研] 085601材料工程315分求调剂 +3 yang_0104 2026-03-15 3/150 2026-03-15 10:58 by peike
[考研] 中科大材料与化工319求调剂 +3 孟鑫材料 2026-03-14 3/150 2026-03-14 20:10 by ms629
[考研] 中科大材料专硕319求调剂 +3 孟鑫材料 2026-03-13 3/150 2026-03-14 18:10 by houyaoxu
[考研] 材料与化工(0856)304求B区调剂 +6 邱gl 2026-03-12 7/350 2026-03-13 23:24 by 邱gl
[考研] 295求调剂 +3 小匕仔汁 2026-03-12 3/150 2026-03-13 15:17 by vgtyfty
信息提示
请填处理意见