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 the Event class. This class only stores information about the events our program will work with. Declare two private attributes: one called the date of the java.util.Date type and the other called the event of the String type. Generate the methods to write and read their values.
  2. Create the WriterTask class and specify that it implements the Runnable interface:
        public class WriterTask implements Runnable {
  1. Declare the queue that stores the events and implement the constructor of the class that initializes this queue:
        private Deque<Event> deque;         public WriterTask (Deque<Event> deque){           this.deque=deque;         }
  1. Implement the run() method of this task. This method will ...

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