O'Reilly logo

Mastering Java 11 - Second Edition by Dr. Edward Lavieri

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

ControlDaemon

The ControlDaemon class implements the Runnable interface and is started as a separate thread. The constructor gets the set of the parameters that were read from the properties files and converts them to a set of ParamsAndHandle objects, shown as follows: 

private final Set<ParamsAndHandle> handlers;  public ControlDaemon(Set<Parameters> params) {  handlers = params.stream()    .map( s -> new ParamsAndHandle(s,null))    .collect(Collectors.toSet());}

Because the processes are not started at this point, the handles are all null. The run() method is used to start the processes, as follows:

@Overridepublic void run() {  try {    for (ParamsAndHandle pah : handlers) {      log.log(DEBUG, "Starting {0}", pah.params); ProcessHandle handle = start(pah.params); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required