A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© aguang 中级黑马   /  2015-8-22 17:39  /  243 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

package cn.tt9;


/*获取线程名称

public final String getName()
设置线程名称:1  setName();    2通过构造方法

获取main方法所在的线程名称
public static Thread currentThread():返回当前正在执行的线程对象   静态,返回Thread
*/
public class Test01 {
        public static void main(String[] args) {
                Mythread my1=new Mythread();
                Mythread my2=new Mythread();
               
                System.out.println(Thread.currentThread().getName());//获取当前进程的名称
                my1.setName("hello");
                my2.setName("收集");
               
                Mythread my3=new Mythread("haha");
                my3.start();
               
                my1.start();
                my2.start();
               
        }
}


0 个回复

您需要登录后才可以回帖 登录 | 加入黑马