public ThreadPoolBuilder withName ( String name ) { // ensure we've got a spot to put the thread id. if ( ! name . contains ( "%d" ) ) { name = name + "-%d" ; } nameMap . putIfAbsent ( name , new AtomicInteger ( 0 ) ) ; int id = nameMap . get ( name ) . incrementAndGet ( ) ; this . poolName = String . format ( name , id ) ; if ( id > 1 ) { this . threadNameFormat = name . replace ( "%d" , id + "-%d" ) ; } else { this . threadNameFormat = name ; } return this ; }
Set the threadpool name . Used to generate metric names and thread names .