ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
时间: 2023-10-20 20:34:31 浏览: 185
对 Java 四种线程池的简要分析
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(); 是创建一个只有一个线程的定时任务执行器。 这个执行器使用了Executors类的newSingleThreadScheduledExecutor()方法来创建。这个方法返回一个ScheduledExecutorService对象,它可以用来执行定时任务。这个执行器只会创建一个线程来执行任务,所以任务之间不会并发执行。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [async-retry:Java 78 的异步重试](https://download.csdn.net/download/weixin_42134537/19380766)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [Executors.newSingleThreadScheduledExecutor()实现定时任务 并解决其发生异常时卡死状态](https://blog.csdn.net/luzhensmart/article/details/103802332)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文