@Override
    public void run() {
        try {
            synchronized (monitor) {
                if (cancelled) return;
                running = true;
            }

            runlet.run();

            synchronized (monitor) {
                running = false;
                if (!cancelled) return;

                if (!periodicExecutionCancellation.isPresent()) {
                    // This should be impossible given the implementation of cancel()
                    throw new IllegalStateException("Cancelled before cancellation callback was set");
                }
            }

            runlet.close();
            periodicExecutionCancellation.get().run();
        } catch (Throwable e) {
            logger.log(Level.SEVERE, "Failed run of periodic execution", e);
        }
    }
Must be called periodically in happens-before order, but may be called concurrently with
{@link #setPeriodicExecutionCancellationCallback(Runnable)} and {@link #cancel()}.
service-monitor/src/main/java/com/yahoo/vespa/service/executor/CancellableImpl.java