public class Fabric extends Thread{

    public static void main(String args[]){
Thread t = new Thread(new Fabric());
Thread t2 = new Thread(new Fabric());
Thread t3 = new Thread(new Fabric()); t.start();
t2.start();
t3.start();
} public void run(){
System.out.println(Thread.currentThread().getName() + ": " + i);
}
}

这段代码的输出为 1,3,5 (无序)

但如果指定线程名则为1,2,3:

public class Fabric extends Thread{

    public static void main(String args[]){
Thread t = new Thread(null, new Fabric(), "1");
Thread t2 = new Thread(null, new Fabric(), "2");
Thread t3 = new Thread(null, new Fabric(), "3"); t.start();
t2.start();
t3.start();
} public void run(){
System.out.println(Thread.currentThread().getName() + ": " + i);
}
}

March 29th, 2015, Thread Name is odd by increasing 1的更多相关文章

  1. Microsoft SQL Server Version List [sqlserver 7.0-------sql server 2016]

    http://sqlserverbuilds.blogspot.jp/   What version of SQL Server do I have? This unofficial build ch ...

  2. Git for Windows v2.11.0 Release Notes

    homepage faq contribute bugs questions Git for Windows v2.11.0 Release Notes Latest update: December ...

  3. qml操作播放器

    现在增加了一个filter属性,所以可以很好和opencv结合.转一篇文章(http://blog.qt.io/blog/2015/03/20/introducing-video-filters-in ...

  4. Diagnosing out of memory errors and memory leaks 内存泄露实例 C Java JavaScript 内存泄露

    小结: 1. 数据库连接池. JDBC语句和结果对象必须显式地关闭. 2. 电梯到目标楼层后地址是否被释放 When a button is pressed: Get some memory, whi ...

  5. Spark版本发布历史,及其各版本特性

      2016年11月5日 We are proud to announce that Apache Spark won the 2016 CloudSort Benchmark (both Dayto ...

  6. KBMMW 4.80.00 发布

    一大波更新来了. 4.80.00 March 30 2015 Important notes (changes that may break existing code)        ======= ...

  7. Lua的各种资源1

    Libraries And Bindings     LuaDirectory > LuaAddons > LibrariesAndBindings This is a list of l ...

  8. Building and running Node.js for Android

    转自: http://www.goland.org/nodejsonandroid/ Building and running Node.js for Android October 14, 2014 ...

  9. Zend Guard Run-time support missing 问题的解决

    Zend Guard是目前市面上最成熟的PHP源码加密产品了. 刚好需要对自己的产品进行加密,折腾了一晚上,终于搞定,将碰到的问题及解决方法记录下来,方便日后需要,也可以帮助其他人. 我使用的是Wam ...

随机推荐

  1. UVA 10635 - Prince and Princess LCS转化为LIS

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  2. [Maven实战](6)仓库(本地仓库,远程仓库,镜像)

    1. 简单介绍 maven能够在某个位置统一存储全部maven项目共享的构件,这个统一的位置就是仓库.实际的Maven项目将不会各自存储其依赖文件,它们仅仅须要声明这些依赖的坐标,在须要的时候(比如. ...

  3. js自动记忆用户名(可以设置cookie多存几天)

    js自动记忆用户名(可以设置cookie多存几天) 一.总结 1.记住密码:因为cookie是存在本地的,也可以多存几天,所以记住密码的操作只需要读取cookie,将其中的账号密码直接显示在输入框就好 ...

  4. 微信端 h5 视频 video 自动播放

    document.addEventListener("WeixinJSBridgeReady",function(){ document.getElementById(" ...

  5. 16、NOR FLASH驱动框架

    mtdram.c是内核自带用内存模拟nor flash程序 physmap.c是内核自带nor flash驱动程序最底层硬件相关层代码 其关键代码是:1.分配一个map_info结构体    2.设置 ...

  6. [Node] Using dotenv to config env variables

    Install: npm install dotenv --save For example, we can store the sensitive information or env relate ...

  7. FZU 1650 1752 a^b mod c

    http://acm.fzu.edu.cn/problem.php?pid=1752 http://acm.fzu.edu.cn/problem.php?pid=1650 给跪了. 我的快速幂会越界. ...

  8. HTTP协议和HTTPS协议初探

    概况 HTTP是hypertext transfer protocol(超文本传输协议)的简写.它是TCP/IP协议的一个应用层协议,用于定义WEB浏览器与WEBserver之间交换数据的过程. HT ...

  9. Loader之一:基本原理 分类: H1_ANDROID 2013-11-16 10:29 1923人阅读 评论(0) 收藏

    参考APIDEMO及http://developer.android.com/guide/components/loaders.html#app 1.Introduced in Android 3.0 ...

  10. UUIDUtils工具类

    原理是根据自身的操作系统和电脑硬件生成的一个32位的随机字符串,如果是一台电脑使用的话,一年不会重复,经过java之后貌似编程了36位,多了4个"-",下面是代码实现: impor ...