Code example for ThreadFactoryBuilder

  public NettyMapOutputHttpServer(int startingPort) throws IOException {
    this.port = startingPort;
  public synchronized void init(Configuration conf) { 
      ThreadFactory bossFactory = new ThreadFactoryBuilder()
        .setNameFormat("ShuffleHandler Netty Boss #%d")
    ThreadFactory workerFactory = new ThreadFactoryBuilder()
        .setNameFormat("ShuffleHandler Netty Worker #%d")
    int maximumPoolSize = conf.getInt(MAXIMUM_THREAD_POOL_SIZE,
    try { 
      workerThreadPool =
        (ThreadPoolExecutor) Executors.newCachedThreadPool(workerFactory);
    } catch (ClassCastException e) {
      LOG.warn("Netty worker thread pool is not of type ThreadPoolExecutor", e);
Connect your IDE to all the code out there  Get Codota for Java