加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 具有相同名称的线程

发布时间:2020-12-15 04:59:18 所属栏目:Java 来源:网络整理
导读:我在 java线程模型api中读过有关 java线程的一件事.它说多个线程可以具有相同的名称.但是每个线程的pid都是唯一的,对吧?那叫什么名字?是不是线程类名? 解决方法 what is the name then? isnot the thread class name? 这个名称是您设置它使用 Thread.setN
我在 java线程模型api中读过有关 java线程的一件事.它说多个线程可以具有相同的名称.但是每个线程的pid都是唯一的,对吧?那叫什么名字?是不是线程类名?

解决方法

what is the name then? isnot the thread class name?

这个名称是您设置它使用Thread.setName的任何名称.它仅用于诊断目的.如果您不调用Thread.setName或将名称提供给构造函数,则将根据文档确定该值:

Allocates a new Thread object. This constructor has the same effect as Thread (null,null,gname),where gname is a newly generated name. Automatically generated names are of the form "Thread-"+n,where n is an integer.

(在诊断上,给出一个指明其用途的特定线程名称显然更有用.)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读