public static ThreadFactory newThreadFactory ( final String format , final boolean daemon ) { final String nameFormat ; if ( ! format . contains ( "%d" ) ) { nameFormat = format + "-%d" ; } else { nameFormat = format ; } return new ThreadFactoryBuilder ( ) // . setNameFormat ( nameFormat ) // . setDaemon ( daemon ) // . build ( ) ; }
Returns a new thread factory that uses the given pattern to set the thread name .