首页 > 解决方案 > 为什么 Spring 的 Restarter 典当另一个线程

问题描述

在调试 SpringBoot 应用程序时,我在 org.springframework.boot.devtools.restart.Restarter 中看到了这段代码

private void immediateRestart() {
        try {
            getLeakSafeThread().callAndWait(() -> {
                start(FailureHandler.NONE);
                cleanupCaches();
                return null;
            });
        }
        catch (Exception ex) {
            this.logger.warn("Unable to initialize restarter", ex);
        }
        SilentExitExceptionHandler.exitCurrentThread();
    }

那么,为什么 Spring 会这样做,为什么不在start(FailureHandler.NONE);当前线程中调用呢?

标签: javaspring

解决方案


推荐阅读