Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExecutorService restart

Can I restart an ExecutorService to start accepting new task after it has been shutdown?

Or I have to always create new ExecutorService instance?

like image 227
pdiddy Avatar asked Sep 12 '25 23:09

pdiddy


2 Answers

If you look at the documentation, there is no method to restart an ExecutorService, as it is an interface without such a method you can infer that there is no way to restart it. That said, as ExecutorService is an interface, you could conceivably write an implementation that does restart (but you would have to reference it by its concrete type or another interface). I wouldn't recommend it though. Just use the existing ones and recreate them as necessary.

like image 161
kabuko Avatar answered Sep 14 '25 13:09

kabuko


I don't see any indication that you can do that from the documentation.

What is the problem with creating new ones?

like image 28
skynet Avatar answered Sep 14 '25 14:09

skynet