Code example for ThreadFactoryBuilder

0
 
public class GuavaNotificationBus implements NotificationBus 
{ 
    private final AtomicReference<AsyncEventBus> stageBus = new AtomicReference<AsyncEventBus>();
 
    private final AsyncEventBus bus = new AsyncEventBus(Executors.newCachedThreadPool(new ThreadFactoryBuilder()
                                                                                          .setDaemon(true)
                                                                                          .setNameFormat("event-bus-%d")
                                                                                          .build()));
 
    @Override 
    public void subscribe(Scope scope, Object listener)
    { 
        if (scope == Scope.Stage) {
            stageBus.get().register(listener);
        } 
        else { 
            bus.register(listener);
        } 
    } 
Contextual code suggestions in your IDE  Get Codota for Java