private static volatile long  testCount=200;

//    @Test
//    public void test() {
//
////        /********************** jdk 8 自带的 ***********************/
//////        Optional.of(); 与guava 相同 不能为为空
//////        Optional.empty() ;   返回 null
//////        Optional.ofNullable()
////
////
////        /********************  Guava   jdk 8 已经有了 ************/
//////        Optional.of(null);
//////        Optional<OptionalTest> test = Optional.absent();
//////        Optional.fromNullable(null);
////
////
//////        XMap map = new XMap("batchId","3004-A1-Z01-FINTRAN-RESULT-000092-20170526");
//////        JSONObject json = new JSONObject();
//////        json.put("batchId","3004-A1-Z01-FINTRAN-RESULT-000092-20170526");
//////        XMap msgmap = new XMap("key",json);
//////
//////        HashMap<String, Object> data = msgmap.getXMap("key");//账户 发送的是对象,架构的原因
//////        XMap data2 = msgmap.getXMap("key");//账户 发送的是对象,架构的原因
//////        System.out.printf(""+data);
////
////        Random a = new Random();
////        Integer b = a.nextInt();
////        String s = "58";
////
////        String randomStr = StringUtils.padLeft(s,3,'0') + String.format("%0"+3+"d",a.nextInt(999));
////
////        System.out.println("hahahaaha===="+randomStr);
//
//        ThreadPoolExecutor executor = new ThreadPoolExecutor(2,5,30, TimeUnit.MINUTES,new ArrayBlockingQueue<Runnable>(10));
//
//        for (int i = 0; i < 100; i++) {
////            executor.execute(new testRun());
//        }
//
//    }

//    private class testRun implements Runnable{
//        @Override
//        public void run() {
//            System.out.println("testlong411111"+testLong);
//            testLong = testLong +1;
//            System.out.println("testlong42{}"+testLong);
//        }
//    }


    public static class WorkerThread implements Runnable{

        CyclicBarrier barrier;

        public WorkerThread(CyclicBarrier b){
            this.barrier = b;
        }

        @Override
        public void run() {
            // TODO Auto-generated method stub
            try{
                barrier.await();
                testCount =testCount-1;

            }catch(Exception e){
                e.printStackTrace();
            }
        }

    }

    /**
     * @param args
     */
    public static void main(String[] args) {
//        // TODO Auto-generated method stub
        CyclicBarrier cb = new CyclicBarrier(100);
        WorkerThread thread = new WorkerThread(cb);
        ThreadPoolExecutor executor = new ThreadPoolExecutor(100,150,30, TimeUnit.MINUTES,new ArrayBlockingQueue<Runnable>(130));
        for(int i=0;i<99;i++){
            executor.execute(new Thread(thread,String.valueOf(i)));

        }
        try {
            cb.await();
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("testLong为"+testCount);
        executor.shutdown();
    }

results matching ""

    No results matching ""