On 04/07/2020 15:44, Martin Buchholz wrote:
On Fri, Jul 3, 2020 at 11:12 PM Alan Bateman <alan.bate...@oracle.com> wrote:

- "service" isn't a great name for the Executor. Also you can make use
of try-finally, e.g.
ExecutorService executor = Executors.newFixedThreadPool(1);
try { ... } finally { executor.shutdown(); }
If you want to do this structured-concurrency-style, you should wait
for all the threads you started to complete (they might block!).
shutdown is not enough - you also want awaitTermination.

There is a future::get in the block so shutdown will be invoked when the task queue is empty, so it should lead to termination. However you are right that if the test throws before this then it may just shutdown while the "Server" task is still running. It could be make a lot more robust.

-Alan

Reply via email to