java new thread run_java thread在run函数中输出status是new

在javathread的run函数中输出当前线程状态,显示结果是new,这是怎么回事?代码如下:publicclassTest{publicstaticvoidmain(String[]args){ThreadPoolExecutorexecutor=newThreadFac...

在java thread的run函数中输出当前线程状态,显示结果是new,这是怎么回事?

代码如下:

public class Test {

public static void main(String[] args){

ThreadPoolExecutor executor = new ThreadFactory(50, 200, 60,

TimeUnit.SECONDS, new ArrayBlockingQueue(1000),

new ThreadPoolExecutor.CallerRunsPolicy());

for(int i=0;i<15;i++){

Task task = new Task();

executor.execute(task);

}

}

}

public class Task extends Thread{

@Override

public void run(){

System.out.println(this.getId() + " "+ this.getName() + ": " + this.getState());

}

}

输出结果:

13 Thread-2: NEW

21 Thread-6: NEW

15 Thread-3: NEW

11 Thread-1: NEW

17 Thread-4: NEW

19 Thread-5: NEW

9 Thread-0: NEW

27 Thread-9: NEW

23 Thread-7: NEW

25 Thread-8: NEW

29 Thread-10: NEW

31 Thread-11: NEW

33 Thread-12: NEW

35 Thread-13: NEW

37 Thread-14: NEW

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值