符合中小企业对网站设计、功能常规化式的企业展示型网站建设
本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...
商城网站建设因基本功能的需求不同费用上面也有很大的差别...
手机微信网站开发、微信官网、微信商城网站...
package concurrent;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Auth: zhouhongliang
* Date:2019/8/1
* CountDownLatch倒计时锁
* 阻塞主线程,等子线程全部执行完之后主线程继续执行
*
*/
public class CountDownLatchDemo {
public static int count = 0;
/**
* 计算1至10000的和
* @param args
*/
public static void main(String[] args) throws InterruptedException {
//定义一个缓冲线程池
ExecutorService executorService = Executors.newCachedThreadPool();
//定义一个倒计时锁
CountDownLatch countDownLatch = new CountDownLatch(10000);
for (int i=1;i<=10000;i++){
final int index = i;
//多个线程执行
executorService.execute(()->{
synchronized (CountDownLatchDemo.class){
try {
count += index;
} catch (Exception e) {
e.printStackTrace();
} finally {
//计数器减1
countDownLatch.countDown();
}
}
});
}
//线程阻塞,知道countDownLatch计数值=0
countDownLatch.await();
System.out.println(count);
//关闭线程池
executorService.shutdown();
}
}
输出结果:50005000
创新互联建站主要从事成都网站设计、网站建设、外贸网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务翼城,十余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792