protected void startBackgroundCheck()

in src/main/java/org/apache/sling/discovery/commons/providers/spi/base/AbstractServiceWithBackgroundCheck.java [198:220]


    protected void startBackgroundCheck(String threadName, final BackgroundCheck check, final Runnable callback, final long timeoutMillis, final long waitMillis) {
        // cancel the current one if it's still running
        cancelPreviousBackgroundCheck();
        
        if (check.check()) {
            // then we're not even going to start the background-thread
            // we're already done
            if (callback!=null) {
                logSilencer.infoOrDebug("backgroundCheck", "backgroundCheck: already done, backgroundCheck successful, invoking callback");
                callback.run();
            } else {
                logSilencer.infoOrDebug("backgroundCheck", "backgroundCheck: already done, backgroundCheck successful. no callback to invoke.");
            }
            return;
        }
        logSilencer.infoOrDebug("backgroundCheck-" + threadName,
                "backgroundCheck: spawning background-thread for '"+threadName+"'");
        backgroundCheckRunnable = new BackgroundCheckRunnable(callback, check, timeoutMillis, waitMillis, threadName);
        Thread th = new Thread(backgroundCheckRunnable);
        th.setName(threadName);
        th.setDaemon(true);
        th.start();
    }