O'Reilly logo

Java 9 Concurrency Cookbook - Second Edition by Javier Fernández González

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

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 ...

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