public void runFor(int value, TimeUnit tu, int averageProcessingTimeMillis) {
        System.out.println("MBean demo running for " + value + " " + tu);
        int count = 0;
        StopWatch runtime = new StopWatch();
        try {
            while (runtime.elapsed(tu) < value) {
                count++;
                int delayMillis = (int) (Math.random() * 2 * averageProcessingTimeMillis);
                monitor.notifyInput(); // simulate receiving an event
                Thread.sleep(delayMillis);  // simulate processing the event
                if (count % 10 == 0) {
                    monitor.notifyFailed(dummyThrowable(count));
                    log(count, "failed");
                } else {
                    monitor.notifyOutput();
                    log(count, null);
                }
            }
        } catch (InterruptedException ignore) {
            // empty by design
        }
    }