/** * Sets a single-threaded executor to this client. All handlers will be * invoked by this executor. Note that the client executor uses a * user thread (not a daemon thread) that needs to be stopped to * exit the program. * * @return the CoAP client */ public CoapClient useExecutor() { this.executor = Executors.newSingleThreadExecutor(new NamedThreadFactory("CoapClient#")); //$NON-NLS-1$ // activates the executor so that this user thread starts deterministically executor.execute(new Runnable() { public void run() { LOGGER.config("Using a SingleThreadExecutor for the CoapClient"); }; }); return this; }
/** * Constructs a new resource that uses the specified amount of threads to * process requests. * * @param name the name * @param threads the number of threads */ public ConcurrentCoapResource(String name, int threads) { super(name); this.threads = threads; setExecutor(Executors.newFixedThreadPool(threads, new NamedThreadFactory("ConcurrentCoapResource-" + name + '#'))); //$NON-NLS-1$ }
/** * Constructs a new resource that uses an executor with as many threads as * there are processors available. * * @param name the name */ public ConcurrentCoapResource(String name) { super(name); this.threads = getAvailableProcessors(); setExecutor(Executors.newFixedThreadPool(threads, new NamedThreadFactory("ConcurrentCoapResource-" + name + '#'))); //$NON-NLS-1$ }
new NamedThreadFactory("CoapServer#")); //$NON-NLS-1$