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

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