I have a question about Thread while developing Java applications.
The code below is the result of a printout of the code into the thread.currentThread();
Thread[ForkJoinPool-1-worker-2,5,main]
Does 1 mean the index of the pool?
Does 2 mean worker number?
I don't know exactly the number meaning of 1, 2, 5.
Thanks.
if you look in ForkJoinPull class you can find one of many constructors
ForkJoinPool(...){
....
this.workerNamePrefix = "ForkJoinPool-" + nextPoolId() + "-worker-";
....
}
wherenextPoolId()
it's poolNumberSequence. After initialization workerNamePrefix will has next value - "ForkJoinPool-1-worker-...".
after that in method final WorkQueue registerWorker(ForkJoinWorkerThread wt) {}
will set thread name in string 1414 (wt.setName(prefix.concat(Integer.toString(tid)))) where wt is ForkJoinWorkerThread and tid are thread's pids.
This name you showed in your output.