- package net.itdos.concurrent;
- import java.util.concurrent.ExecutorService;
- import java.util.concurrent.Executors;
- import java.util.concurrent.atomic.AtomicInteger;
- public class TestConcurrent {
- java.util.concurrent.atomic.AtomicInteger mm = new AtomicInteger(4);
- public void gg(){
- ExecutorService pool = Executors.newFixedThreadPool(5);
- for(int i = 0; i <10 ;i++){
- final int gg = i;
- pool.execute(new Runnable() {
- @Override
- public void run() {
- // TODO Auto-generated method stub
- System.out.println(Thread.currentThread().getName() + ":"+gg);
- }
- });
- }
- pool.shutdown();
- }
- public static void main(String[] kl){
- new TestConcurrent().gg();
- }
- }
java5 新增线程池的使用
最新推荐文章于 2022-07-10 16:57:39 发布