private String nextThreadName(){
  Class<?> cls=getClass();
  int newThreadId;
  AtomicInteger threadId=threadIds.putIfAbsent(cls,new AtomicInteger(1));
  if (threadId == null) {
    newThreadId=1;
  }
 else {
    newThreadId=threadId.incrementAndGet();
  }
  return cls.getSimpleName() + '-' + newThreadId;
}

private String nextThreadName ( ) { Class < ? > cls = getClass ( ) ; int newThreadId ; AtomicInteger threadId = threadIds . putIfAbsent ( cls , new AtomicInteger ( 1 ) ) ; if ( threadId == null ) { newThreadId = 1 ; } else { newThreadId = threadId . incrementAndGet ( ) ; } return cls . getSimpleName ( ) + '-' + newThreadId ; }
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 .
