java - meaning of pool number in default name of thread in ScheduledExecutorService -


i using scheduledexecutorservice maintain thread pool of core size 10

scheduledexecutorservice visiblitythreadpool = executors.newscheduledthreadpool(10);

now in log see thredname pool-39-thread-3 .

i ok thread number 3 assuming thread number can vary 1 10 how come pool number in name in 39 ?

what 39 indicates here ? please put light on it.

that string name prefix thread objects initialized java.util.concurrent.executors$defaultthreadfactory.

the source code of class looks like

/**  * default thread factory  */ static class defaultthreadfactory implements threadfactory {     private static final atomicinteger poolnumber = new atomicinteger(1);     private final threadgroup group;     private final atomicinteger threadnumber = new atomicinteger(1);     private final string nameprefix;      defaultthreadfactory() {         securitymanager s = system.getsecuritymanager();         group = (s != null) ? s.getthreadgroup() :                               thread.currentthread().getthreadgroup();         nameprefix = "pool-" +                       poolnumber.getandincrement() +                      "-thread-";     }      public thread newthread(runnable r) {         thread t = new thread(group, r,                               nameprefix + threadnumber.getandincrement(),                               0);         if (t.isdaemon())             t.setdaemon(false);         if (t.getpriority() != thread.norm_priority)             t.setpriority(thread.norm_priority);         return t;     } } 

the number following pool- therefore generated atomicinteger stored in static field. each defaultthreadfactory instance gets "id" of sorts, representing how many others instances initialized before (+1).

since executorservice factory methods in executors make use of defaultthreadfactory, can assume number represents how many thread pools created through executorservice.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -