How to do it...

Follow these steps to implement the example:

  1. Create a class named Operation with three attributes: a String attribute named user, a String attribute named operation, and a Date attribute named time. Add the methods to get and set the values of the attributes. The code of this class is very simple, so it won't be included here.
  2. Create a class named HashFiller. Specify that it implements the Runnable interface:
        public class HashFiller implements Runnable {
  1. Declare a private ConsurrentHashMap attribute named userHash. The key of the hash will be a String type and its value will be a ConcurrentLinkedDeque object of Operation objects. Implement the constructor of the class to initialize the attribute:
 private ConcurrentHashMap<String, ...

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.