code: public boolean offer(Runnable o) {
          int poolSize = threadPoolExecutor.getPoolSize();
  
          // we are maxed out on threads, simply queue the object
          if (poolSize == threadPoolExecutor.getMaximumPoolSize()) {
              return super.offer(o);
          }
          // we have idle threads, just add it to the queue
          // note that we don't use getActiveCount(), see BZ 49730
          if (threadPoolExecutor.getSubmittedTasksCount() <= poolSize) {
              return super.offer(o);
          }
          // if we have less threads than maximum force creation of a new
          // thread
          if (poolSize < threadPoolExecutor.getMaximumPoolSize()) {
              return false;
          }
          // if we reached here, we need to add it to the queue
          return super.offer(o);
      }
docs: 注：tomcat的代码进行一些小变更