Code example for ThreadFactoryBuilder

    // This will create its own client socket channel factory. 
    protected HedwigClientImpl(ClientConfiguration cfg) {
        this(cfg, new NioClientSocketChannelFactory(
                Executors.newCachedThreadPool(new ThreadFactoryBuilder()
                Executors.newCachedThreadPool(new ThreadFactoryBuilder()
        ownChannelFactory = true;
    // Constructor that takes in a Configuration object and a ChannelFactory 
    // that has already been instantiated by the caller. 
    protected HedwigClientImpl(ClientConfiguration cfg, ChannelFactory socketFactory) {
        this.cfg = cfg;
        this.socketFactory = socketFactory;
        if (cfg.isSubscriptionChannelSharingEnabled()) {
            channelManager = new MultiplexHChannelManager(cfg, socketFactory);
        } else { 
            channelManager = new SimpleHChannelManager(cfg, socketFactory);
Experience pair programming with AI  Get Codota for Java