Java Reference
In-Depth Information
can wait for an
ExecutorService
to reach the terminated state with
awaitTermin-
ation
, or poll for whether it has yet terminated with
isTerminated
. It is common to
follow
shutdown
immediately by
awaitTermination
, creating the effect of synchron-
ously shutting down the
ExecutorService
.(
Executor
shutdown and task cancellation
are covered in more detail in
Chapter 7
.)
LifecycleWebServer
in
Listing 6.8
extends our web server with lifecycle support. It
can be shut down in two ways: programmatically by calling
stop
, and through a client re-
quest by sending the web server a specially formatted HTTP request.