24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 467  |  回复: 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的回帖

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的回帖
查看全部 3 个回答

sj1314

版主

优秀!!有木有!!!优秀!!有木有!!!优秀!!有木有!!!优秀!!有木有!!!

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

发自小木虫Android客户端
2楼2016-05-23 09:28:23
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 一志愿 南京航空航天大学 ,080500材料科学与工程学硕 +5 @taotao 2026-03-31 5/250 2026-03-31 23:08 by liu823948201
[考研] 267求调剂 +9 uiybh 2026-03-31 9/450 2026-03-31 22:15 by 天倌赐福
[考研] 一志愿北京科技大学材料学硕328分求调剂 +4 1段时间 2026-03-31 5/250 2026-03-31 19:56 by wxiongid
[考研] 化学308分调剂 +11 你好明天你好 2026-03-30 12/600 2026-03-31 19:14 by 杨金金金
[考研] 材料科学与工程339求调剂 +3 hyz0119 2026-03-31 3/150 2026-03-31 18:31 by 1939136013狗壮
[考研] 085600,321分求调剂 +7 大馋小子 2026-03-31 7/350 2026-03-31 18:02 by 无际的草原
[考研] 求化学调剂 +12 wulanna 2026-03-28 12/600 2026-03-31 16:38 by 690616278
[考研] 材料与化工(0856)304求B区调剂 +6 邱gl 2026-03-30 11/550 2026-03-31 16:34 by 邱gl
[考研] 调剂310 +13 温柔的晚安 2026-03-25 14/700 2026-03-31 13:03 by 记事本2026
[考研] 287求调剂 +17 land xuxu 2026-03-26 17/850 2026-03-31 11:16 by Zzxxxs
[考研] 083000学硕274求调剂 +12 Li李鱼 2026-03-26 12/600 2026-03-31 10:01 by cal0306
[考研] 0856调剂 +6 曲听筠 2026-03-30 6/300 2026-03-31 09:44 by Jaylen.
[考研] 291求调剂 +12 Y-cap 2026-03-29 15/750 2026-03-31 09:25 by Huaxue_Wang
[考研] 材料专硕 085600求调剂 +7 BBQ233 2026-03-30 7/350 2026-03-30 17:44 by oooqiao
[考研] 295求调剂 +5 wei-5 2026-03-26 5/250 2026-03-30 08:34 by 探123
[考研] 一志愿厦门大学化学学硕307求调剂 +10 y7czhao 2026-03-26 10/500 2026-03-28 14:23 by 唐沐儿
[考研] 一志愿郑大085600,310分求调剂 +5 李潇可 2026-03-26 5/250 2026-03-27 11:14 by 不吃魚的貓
[考研] 081200-11408-276学硕求调剂 +3 崔wj 2026-03-26 3/150 2026-03-26 19:57 by nihaoar
[考研] 一志愿 南京邮电大学 288分 材料考研 求调剂 +3 jl0720 2026-03-26 3/150 2026-03-26 13:39 by zzll406
[考研] 化学调剂一志愿上海交通大学336分-本科上海211 +4 小鱼爱有机 2026-03-25 4/200 2026-03-26 10:19 by aa331100
信息提示
请填处理意见