How to do it...

Follow these steps to implement the example:

  1. Create a class named Contact:
        public class Contact {
  1. Declare two private String attributes named name and phone:
        private final String name;         private final String phone;
  1. Implement the constructor of the class to initialize its attributes:
        public Contact(String name, String phone) {           this.name=name;           this.phone=phone;         }
  1. Implement the methods to return the values of the name and phone attributes:
        public String getName() {           return name;         }          public String getPhone() {           return phone;         }
  1. Create a class named Task and specify that it implements the Runnable interface:
        public class Task implements Runnable {
  1. Declare a private ConcurrentSkipListMap attribute, parameterized ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.