/** * Get a new {@link RingoWorker}. * * @return a worker instance. */ public RingoWorker getWorker() { RingoWorker worker = workers.pollFirst(); if (worker == null) { worker = new RingoWorker(this); } return worker; }
/** * Return a worker, returning it to the worker pool. * * @param worker the worker to be released */ void returnWorker(RingoWorker worker) { if (!workers.offerFirst(worker)) { worker.shutdown(); } }