首页 > 学院 > 开发设计 > 正文

java 多线程,线程号不同,但线程名称相同

2019-11-14 12:12:20
字体:
来源:转载
供稿:网友

package quartztest;

import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit;

public class MuiltThreads {

public static void main(String[] args){ BlockingQueue<Runnable> workQueue=new LinkedBlockingDeque<Runnable>(); ThreadPoolExecutor poolExecutor=new ThreadPoolExecutor(5, 5, 60, TimeUnit.SECONDS, workQueue); for(int i =0 ;i< 10;i++){ Thread a = new Thread(new Runnable() { @Override public void run() { System.out.PRintln("xxxxxxxx"); } }); a.setName("111"); System.out.println("xxx"+a.getId() + a.getName()); poolExecutor.execute(a); };}

}


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表