Java线程池不执行run命令

Sha*_*s88 5 java multithreading threadpoolexecutor

我有一个奇怪的情况。我有一个包含 1 个核心工作人员和 5 个最大工作人员的线程池。我提供了最多 5000 个项目的阻塞队列。每当我向该池提交任务时,它就会排队。什么都没发生。没有错误,没有例外。我已经在所有可能的地方添加了前处理程序。Runnable 对象被初始化,但 run() 方法永远不会执行。请帮忙

线程池:

BlockingQueue<Runnable> workQueue = new LinkedBlockingDeque<>(5000);
private ThreadPoolExecutor taskExecutor = new ThreadPoolExecutor(1, 5, 30, TimeUnit.SECONDS, workQueue);
Run Code Online (Sandbox Code Playgroud)

任务插入:

我正在从数据库中读取 n 条记录,将其分成块并将块的起始号和结束号提供给工作人员。

do {
   try {
        taskExecutor.execute(new EmailWorker(lowerOffset, upperOffset));
        logger.trace("Added work: seq:"+lowerOffset+" to seq no:"+upperOffset+" to executor pool");
        lowerOffset = lowerOffset + (batchSize-1) + 1;
        upperOffset = lowerOffset + (batchSize-1);
        Thread.sleep(500);
    } catch(RejectedExecutionException ree) {
        logger.trace("Too many work items. Pausing for a while, let Email workers catch up."+ree.getMessage());
        try {
            Thread.sleep(10000);
        } catch (InterruptedException ex) {

        }

   } catch (CriticalException ex) {
        throw ex;
   } catch (InterruptedException ex) {
      logger.error("", ex);
   } catch (Exception ex) {
      logger.error("",ex);
   }            
} while(upperOffset <= maxSeqNo);
Run Code Online (Sandbox Code Playgroud)

在工作人员中,我在 run 方法中有以下结构。由于我在开始时已尝试阻止,因此无论如何都应该捕获其中发生的任何错误。

public void run() {
    logger.trace("email worker work started");
    ResultSet rs = null;

    try {
        //
    } catch (SQLException | ClassNotFoundException sq) {
        kafkaLogger.error(sq.getClass() + " :: " + sq.getMessage());
        logger.error(sq.getMessage());
    } catch (Exception sq) {
        kafkaLogger.error(sq.getClass() + " :: " + sq.getMessage());
        logger.error(sq.getMessage());
    }

}
Run Code Online (Sandbox Code Playgroud)

这是线程池的输出

[2018-01-15 19:03:46] :: TRACE :: EmailSupervizor:156 - [Running, pool size = 2, active threads = 1, queued tasks = 1, completed tasks = 0]
[2018-01-15 19:03:51] :: TRACE :: EmailSupervizor:157 - [Running, pool size = 1, active threads = 1, queued tasks = 2, completed tasks = 0]
[2018-01-15 19:03:56] :: TRACE :: EmailSupervizor:160 - [Running, pool size = 1, active threads = 1, queued tasks = 3, completed tasks = 0]
[2018-01-15 19:03:61] :: TRACE :: EmailSupervizor:156 - [Running, pool size = 2, active threads = 1, queued tasks = 4, completed tasks = 0]
Run Code Online (Sandbox Code Playgroud)