@Test public void test007ExecutorService正常运行() throws Exception { ThreadPoolExecutor executor = RetryUtil.createThreadPoolExecutor(); for (int i = 0; i < 10; i++) { executor.submit(new Callable<Object>() { @Override public Object call() throws Exception { TimeUnit.SECONDS.sleep(4); return null; } }); System.out.println("Submit: " + i + ", running tasks: " + executor.getActiveCount()); TimeUnit.SECONDS.sleep(1); } }
public static ThreadPoolExecutor createThreadPoolExecutor() { return new ThreadPoolExecutor(0, 5, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>()); }
RetryUtil { public static ThreadPoolExecutor createThreadPoolExecutor() { return new ThreadPoolExecutor(0, 5, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>()); } }
RetryUtil { public static ThreadPoolExecutor createThreadPoolExecutor() { return new ThreadPoolExecutor(0, 5, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>()); }  }
RetryUtil { public static ThreadPoolExecutor createThreadPoolExecutor() { return new ThreadPoolExecutor(0, 5, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>()); }  static T executeWithRetry(Callable<T> callable,
                                         int retryTimes,
                                         long sleepTimeInMilliSecond,
                                         boolean exponential); static T executeWithRetry(Callable<T> callable,
                                         int retryTimes,
                                         long sleepTimeInMilliSecond,
                                         boolean exponential,
                                         List<Class<?>> retryExceptionClasss); static T asyncExecuteWithRetry(Callable<T> callable,
                                              int retryTimes,
                                              long sleepTimeInMilliSecond,
                                              boolean exponential,
                                              long timeoutMs,
                                              ThreadPoolExecutor executor); static ThreadPoolExecutor createThreadPoolExecutor(); }
RetryUtil { public static ThreadPoolExecutor createThreadPoolExecutor() { return new ThreadPoolExecutor(0, 5, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>()); }  static T executeWithRetry(Callable<T> callable,
                                         int retryTimes,
                                         long sleepTimeInMilliSecond,
                                         boolean exponential); static T executeWithRetry(Callable<T> callable,
                                         int retryTimes,
                                         long sleepTimeInMilliSecond,
                                         boolean exponential,
                                         List<Class<?>> retryExceptionClasss); static T asyncExecuteWithRetry(Callable<T> callable,
                                              int retryTimes,
                                              long sleepTimeInMilliSecond,
                                              boolean exponential,
                                              long timeoutMs,
                                              ThreadPoolExecutor executor); static ThreadPoolExecutor createThreadPoolExecutor();  }