提交 4b5567a6 编写于 作者: 智布道's avatar 智布道 👁

Merge branch 'master' of github.com:zhangyd-c/OneBlog

package com.zyd.blog.runner; package com.zyd.blog.runner;
import cn.hutool.core.thread.ThreadFactoryBuilder;
import com.zyd.blog.core.schedule.ArticleLookTask; import com.zyd.blog.core.schedule.ArticleLookTask;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -8,6 +9,8 @@ import org.springframework.boot.ApplicationArguments; ...@@ -8,6 +9,8 @@ import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.concurrent.*;
/** /**
* 执行保存文章浏览记录任务 * 执行保存文章浏览记录任务
* *
...@@ -25,7 +28,14 @@ public class TaskRunner implements ApplicationRunner { ...@@ -25,7 +28,14 @@ public class TaskRunner implements ApplicationRunner {
@Override @Override
public void run(ApplicationArguments args) { public void run(ApplicationArguments args) {
log.info("博客部署完成,博客访问地址:http://localhost:" + port); ThreadFactory articleLookThreadFactory = new ThreadFactoryBuilder().setNamePrefix("BLOG-ARTICLE_LOOK-").build();
articleLookTask.save();
ExecutorService singleThreadPool = new ThreadPoolExecutor(1, 1,
3650L, TimeUnit.DAYS,
new LinkedBlockingQueue<Runnable>(1024),
articleLookThreadFactory, new ThreadPoolExecutor.AbortPolicy());
singleThreadPool.execute(()-> articleLookTask.save());
singleThreadPool.shutdown();
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册