How is default new thread name given in java?

前端 未结 4 1739
无人及你
无人及你 2020-12-11 03:55

When I run this program

public class Fabric extends Thread {
    public static void main(String[] args) {
        Thread t1 = new Thread(new Fabric());
              


        
4条回答
  •  暖寄归人
    2020-12-11 04:43

    The default numeric value in the Thread name is an incremented value unless the name is specified when creating the Thread. Fabric extends Thread, and you are passing the Fabric instance to create another Thread - thus the internal Thread counter is incremented twice as 2 threads are created during the process.

提交回复
热议问题