@Override
    public void run() {
        long timeoutMS = SystemTimer.adjustTimeoutByDetectedHz(Duration.ofMillis(100)).toMillis();
        while (true) {
            Task task = null;
            synchronized (this) {
                if (queue.isEmpty()) {
                    try {
                        if (children.isEmpty()) {
                            wait();
                        } else {
                            wait(timeoutMS);
                        }
                    } catch (InterruptedException e) {
                        continue;
                    }
                }
                if (!queue.isEmpty()) {
                    task = queue.poll();
                }
            }
            if (task == TERMINATE) {
                break;
            }
            if (task != null) {
                try {
                    task.run();
                } catch (Exception e) {
                    log.log(Level.SEVERE, "An exception was thrown while running " + task.getClass().getName(), e);
                }
                try {
                    task.destroy();
                } catch (Exception e) {
                    log.warning("An exception was thrown while destroying " + task.getClass().getName() + ": " + e);
                    log.warning("Someone, somewhere might have to wait indefinitely for something.");
                }
            }
            for (Task child : children) {
                child.run();
            }
        }
        for (Task child : children) {
            child.destroy();
        }
        synchronized (this) {
            while (!queue.isEmpty()) {
                Task task = queue.poll();
                task.destroy();
            }
            notify();
        }
    }
<p>Sets the destroyed flag to true. The very first time this method is
called, it cleans up all its dependencies.  Even if you retain a
reference to this object, all of its content is allowed to be garbage
collected.</p>

@return True if content existed and was destroyed.
messagebus/src/main/java/com/yahoo/messagebus/Messenger.java