final int total
= 3;
ExecutorService executors
= Executors
.newScheduledThreadPool(total
);
final CountDownLatch c
= CountDownLatch(total
);
final AtomicInteger ai
= new AtomicInteger(0);
for(int i
=0;i
<total
;i
++){
executors
.execute(new Runnable(){
@Override
public void run(){
Long currentTime
= System
.currentTimeMillis();
Long spendTime
= System
.currentTimeMills() - currentTime
;
log
.info(new Date()+":"+ai
.incrementAndGet()+" threads have done!");
c
.countDown();
}
});
}
try{
c
.await();
log
.info("............")
executors
.shutdown();
}catch(InterruptedException e
){
log
.info(e
)
}
转载请注明原文地址: https://www.6miu.com/read-3650161.html