code: private String nextThreadName() {
          Class<?> cls = getClass();
          int newThreadId;
  
          // We synchronize this block to avoid a concurrent access to 
          // the actomicInteger (it can be modified by another thread, while
          // being seen as null by another thread)
          synchronized (threadIds) {
              // Get the current ID associated to this class' name
              AtomicInteger threadId = threadIds.get(cls);
  
              if (threadId == null) {
                  // We never have seen this class before, just create a
                  // new ID starting at 1 for it, and associate this ID
                  // with the class name in the map.
                  newThreadId = 1;
                  threadIds.put(cls, new AtomicInteger(newThreadId));
              } else {
                  // Just increment the lat ID, and get it.
                  newThreadId = threadId.incrementAndGet();
              }
          }
  
          // Now we can compute the name for this thread
          return cls.getSimpleName() + '-' + newThreadId;
      }
docs: Compute the thread ID for this class instance. As we may have different
  classes, we store the last ID number into a Map associating the class
  name to the last assigned ID.
  
  @return a name for the current thread, based on the class name and
  an incremental value, starting at 1.