How to do it...

Follow these steps to implement the example:

  1. Create a class named Result to store the results generated in the concurrent tasks of this example:
        public class Result {
  1. Declare two private attributes, namely a String attribute called name and an int attribute named value:
        private String name;         private int value;
  1. Implement the corresponding get() and set() methods to set and return the value of the name and value attributes:
        public String getName() {           return name;         }         public void setName(String name) {           this.name = name;         }         public int getValue() {           return value;         }         public void setValue(int value) {           this.value = value;         }
  1. Create a class named Task that implements the Callable interface parameterized by the Result ...

Get Java 9 Concurrency Cookbook - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.