public void run() {
        if (queue == null) {
            throw new NullPointerException("channel is not allowed to be null");
        }

        // TODO: Make the logmessage elements some kind of composite structure to handle both individual messages and lists uniformly.
        List<ItemOrList> drainList = new ArrayList<>(queue.size() + 1);
        try {
            for (; ; ) {
                drainList.clear();
                // block in take(), then see if there is more
                // to be had with drainTo()
                drainList.add(queue.take());
                queue.drainTo(drainList);

                for (int i = 0; i < drainList.size(); i++) {
                    // we can get two types of elements here: single log
                    // messages or lists of log messages, so we need to
                    // handle them accordingly.
                    ItemOrList o = drainList.get(i);
                    drainList.set(i, null);

                    if (o.item != null) {
                        for (LogHandler handler : handlers) {
                            handler.handle(o.item);
                        }
                    } else if (o.list != null) {
                        for (LogHandler handler : handlers) {
                            handler.handle(o.list);
                        }
                    } else {
                        throw new IllegalArgumentException("not LogMessage or List: " + o);
                    }
                }
            }
        } catch (InterruptedException e) {
            // NOP
        } catch (Throwable t) {
            if (fatalErrorHandler != null) {
                fatalErrorHandler.handle(t, null);
            }
        } finally {
            log.fine("Handler thread "
                             + getName()
                             + " exiting, removing handlers");
            for (LogHandler handler : handlers) {
                log.fine("Removing handler " + handler);
                handler.close();
            }
            handlers.clear();
            log.fine("Handler thread " + getName() + " done");
        }

    }
Consume messages from the incoming queue and hand
them off to the handlers.
logserver/src/main/java/com/yahoo/logserver/handlers/HandlerThread.java