标签:void else rri link bsp locking build ipa ide
private ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat("billService-pool-%d").build();
private final ExecutorService pool = new ThreadPoolExecutor(20, 20,0L, TimeUnit.MILLISECONDS,new LinkedBlockingQueue<Runnable>(512),threadFactory);
//解析实例:
final CountDownLatch countDownLatch = new CountDownLatch(billUploadHistory.size());//线程统计 for (BillUpload billUpload : billUploadHistory) { pool.execute(new Runnable() { @Override public void run() { PaybillParser parseService = null; if (EnumTypeOfInt.PAY_CHANNEL_WECHAT.getValue().equals(billUpload.getPayChannel())) { parseService = new WeixinPaybillParser(billUpload, logId); } else if (EnumTypeOfInt.PAY_CHANNEL_ALIPAY.getValue().equals(billUpload.getPayChannel())) { parseService = new AliPaybillParser(billUpload, logId); } if (parseService != null) { try { parseService.parse(); } catch (Exception e) { e.printStackTrace(); } finally { countDownLatch.countDown();//线程减1 } } } }); } try { countDownLatch.await();//阻塞直到计数器为0 } catch (InterruptedException e) { e.printStackTrace(); }
标签:void else rri link bsp locking build ipa ide
原文地址:https://www.cnblogs.com/xwjBlog/p/9208238.html