成功的路上总是离不开贵人的帮助,名师的指点和小人的刺激。

莫怕,过了桥,就翻篇了

1.6getId()方法

getId()方法的作用是取得线程的唯一标识。

 1 package com.cky.test;
 2 
 3 /**
 4  * Created by chenkaiyang on 2017/12/2.
 5  */
 6 public class Test {
 7     public static void main(String[] args){
 8         Thread thread = Thread.currentThread();
 9         System.out.println(thread.getName() +"...."+thread.getId());
10     }
11 }

结果分析当前执行代码的线程名称为main,线程id值为1

posted on 2017-12-03 14:07  痞子陈2016  阅读(487)  评论(0编辑  收藏  举报

导航