Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自动加载线程没有在容器停止时正确停止 #63

Closed
JarkimZhu opened this issue Jan 24, 2019 · 1 comment
Closed

自动加载线程没有在容器停止时正确停止 #63

JarkimZhu opened this issue Jan 24, 2019 · 1 comment

Comments

@JarkimZhu
Copy link

AutoLoadHandler 在启动了守护进程时,没有正确处理shutdown方法,原因如下:

class AutoLoadRunnable implements Runnable {

        @Override
        public void run() {
            while (running) {
                try {
                    // 关键是take方法,take方法会阻塞线程,但因为容器已经shutdown了,
                    // 也不会有数据put进来,导致该守护线程一直阻塞,容器不能正确停止。
                    // 建议改为 autoLoadQueue.poll(long timeout, TimeUnit unit);
                    AutoLoadTO tmpTO = autoLoadQueue.take();
                    if (null != tmpTO) {
                        loadCache(tmpTO);
                        Thread.sleep(config.getAutoLoadPeriod());
                    }
                } catch (InterruptedException e) {
                    log.error(e.getMessage(), e);
                }
            }
        }
... ...
}
@qiujiayu
Copy link
Owner

CacheHandler.destroy()方法会关闭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants