如何设置名称的线程? [英] How to set name to the thread?

查看:110
本文介绍了如何设置名称的线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来设置一个友好的名称,在code线程?

Is there a way to set a friendly name to a thread in code?

例如,我想用的名字螺纹11上的图像上的线被命名为类似MyImportThread。

For example, I want the thread with name Thread-11 on the image was named something like 'MyImportThread'.

推荐答案

您可以很容易地通过一个线程的名字在它的构造。或拨打以下方法

You can easily pass a thread name in Its Constructor. or by calling below method

public final void setName (String threadName)
Sets the name of the Thread.
Parameters
threadName  the new name for the Thread

Thread.currentThread()的setName(线程11);

这篇关于如何设置名称的线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆