<commit_before>package zhongqiu.common.jdk5.concurrent;

import java.util.concurrent.*;

/**
 * ScheduledThreadPoolExecutor 调度线程池
 */
public class ScheduledThreadPoolExecutorDemo {
    static ScheduledExecutorService scheduledThreadPool = new ScheduledThreadPoolExecutor(5);

    public static void main(String[] args) {

    }

    // 延迟1s后开始执行，只执行一次，没有返回值<commit_msg>first version<commit_after>package zhongqiu.common.jdk5.concurrent;

import java.util.concurrent.*;

/**
 * ScheduledThreadPoolExecutor 调度线程池
 * schedule，scheduleWithFixedDelay，scheduleWithFixedRate。三个方法内部都是调用的delayedExecute方法
 * delayedExecute方法: 一、如果线程池shutdown，拒绝任务。二、delayedWorkQueue.add(task)。
 *                     三、ensurePrestart(),确保至少一个线程在处理任务，即使核心线程数corePoolSize为0
 * ensurePrestart方法：一、如果线程数量小于coreSize，addWorker(null, true)。二、否则，如果coreSize=0，addWorker(null,false)
 * addWorker->runWorker->getTask->delayedWorkQueue.take(阻塞，直到延迟队列的第一个元素到达了过期时间)->运行run方法
 */
public class ScheduledThreadPoolExecutorDemo {
    static ScheduledExecutorService scheduledThreadPool = new ScheduledThreadPoolExecutor(5);

    public static void main(String[] args) {

    }

    // 延迟1s后开始执行，只执行一次，没有返回值
{'fraction_non_alphanumeric': 0.09802235597592433, 'fraction_numerical': 0.006878761822871883, 'mean_word_length': 6.054545454545455, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2565413', 'n_tokens_mistral': 443, 'n_tokens_neox': 464, 'n_words': 47}