Java ServiceExecutor terminating condition

后端 未结 4 1854
我在风中等你
我在风中等你 2021-01-22 07:21

I\'m new to java executor stuff.

I\'m using Java\'s ExecutorService to launch several threads to process data.

Executor executor = Executors.newFixedThre         


        
4条回答
  •  囚心锁ツ
    2021-01-22 07:45

    you can think of it that way:

    shutdown() will just tell the executor service that it can't accept new tasks, but the already submitted tasks continue to run

    shutdownNow() will do the same AND will try to cancel the already submitted tasks by interrupting the relevant threads. Note that if your tasks ignore the interruption, shutdownNow will behave exactly the same way as shutdown.

提交回复
热议问题