Skip to content

关闭不优雅 #16

@LongLongATime

Description

@LongLongATime

ThreadPoolImpl.destroy调用的是ThreadPoolExecutor.shutdown方法,该方法会把线程池状态设置为SHUTDOWN,不会接收新任务,并中断线程池里空闲的线程(中断信号并不代表线程会停止,需要线程监听中断信号)。但不会阻塞等待线程池队列里的任务执行完成,这会导致队列中的任务丢弃。可以参考Spring的ThreadPoolTaskExecutor.shutdown方法,在ThreadPoolExecutor.shutdown后,执行ThreadPoolExecutor.awaitTermination等待队列中的任务完成后才停止应用。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions