package com.huatek.busi.config;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.atomic.AtomicInteger;

@Slf4j
public class PrintingPolicy implements RejectedExecutionHandler {

  private final static AtomicInteger rejectedCount = new AtomicInteger(0);

  @Override
  public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
    rejectedCount.incrementAndGet();
    log.warn("Task rejected {}, [{}]被[{}]抛弃了！", rejectedCount, r, executor);
  }
}
