Thread names with implementing Runnable and extending Thread class
This question already has an answer here:
In the second example, the tp
class calls its parent constructor. Since its parent is Thread
, the tp
object in main
+ gets the first auto-assigned name ( Thread-0
).
You should never rely on the auto-generated name. If a name is important to you, call the Thread constructor that allows you to set your own name.
+Side note: Don't name Classes and variables with the same name as you introduce ambiguity.
链接地址: http://www.djcxy.com/p/16394.html上一篇: 中断或停止睡眠线程