Is there any way to distinguish the main Thread from any Threads that it spawns?

前端 未结 3 848
予麋鹿
予麋鹿 2021-01-05 23:09

I know that the getName() function on the main thread will return the String main, but this can be changed with setName().

Is

3条回答
  •  执笔经年
    2021-01-05 23:30

    One possibility is to call Thread.currentThread() at the start of main(), and hold on to the reference.

提交回复
热议问题