public static void asyncWithReturn()

in src/main/java/com/aliyun/mns/common/utils/ThreadUtil.java [104:129]


    public static void asyncWithReturn(ThreadPoolExecutor threadPoolExecutor, Integer maxThreadNum,final AsyncRunInterface asyncRunInterface){
        if (maxThreadNum == null || maxThreadNum < 1) {
            maxThreadNum = 50;
        }

        List<Future<?>> futures = new ArrayList<Future<?>>();
        for (int i = 0; i < maxThreadNum; i++) {
            Future<?> future = threadPoolExecutor.submit(new Runnable() {
                @Override
                public void run() {
                    asyncRunInterface.run();
                }
            });
            futures.add(future);
        }

        // 等待所有异步任务完成
        for (Future<?> future : futures) {
            try {
                future.get(); // 如果任务已完成则立即返回,否则会阻塞等待
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }