private static final ThreadPoolExecutor executor = new ThreadPoolExecutor(32, 128, 120, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(512),
r -> {
Thread t = new Thread(r);
t.setUncaughtExceptionHandler((th, e) ->
logger.error(LogBuilder.log("ThreadPoolExecutor", "uncaught exception," + th.getName()), e)
);
t.setName("th" + t.getId());
return t;
},
(r, exec) -> {
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
throw new RejectedExecutionException("Task " + r.toString() +
" rejected from " +
e.toString());
}

exec.getQueue().add(r);
});

相关文章:

  • 2021-11-20
  • 2022-01-18
  • 2022-12-23
  • 2021-06-18
  • 2021-10-16
  • 2022-12-23
  • 2022-02-12
  • 2021-12-22
猜你喜欢
  • 2021-12-25
  • 2021-10-22
  • 2022-12-23
  • 2021-04-27
  • 2021-12-30
  • 2021-08-01
  • 2021-11-02
相关资源
相似解决方案