How to do it...

Follow these steps to implement the example:

  1. Create a class named Operations:
        public class Operations {
  1. Implement a public static method named readData(). It puts the current thread to sleep for 500 milliseconds:
        public static void readData(){           try {             TimeUnit.MILLISECONDS.sleep(500);           } catch (InterruptedException e) {             e.printStackTrace();           }         }
  1. Implement a public static method named writeData(). It puts the current thread to sleep for 500 milliseconds:
        public static void writeData(){           try {             TimeUnit.MILLISECONDS.sleep(500);           } catch (InterruptedException e) {             e.printStackTrace();           }         }
  1. Implement a public static method named processData(). It puts the current thread to sleep for 2,000 milliseconds:
 public ...

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.