什么定义了“活动”线? [英] What defines an "active" thread?
问题描述
在Java并发中,什么使得线程活动?只是事实,它不是空转?
In Java concurrency, what makes a thread "active"? Just the fact that it's not idling? Is a "waiting" or "suspended" thread still considered, technically, active?
推荐答案
从我可以告诉的术语等待活动似乎被使用了很多,但从来没有定义。 ThreadGroup.enumerate()
方法记录到:
From what I can tell the term 'active' seems to be used a lot but not ever defined. The ThreadGroup.enumerate()
method is documented to:
复制到指定的数组每个活动线程
组及其子组。
Copies into the specified array every active thread in this thread group and its subgroups.
和查看此的来源,它是检查 Thread.isAlive()
方法并将它们添加到枚举。从这里我推断,术语活动和活着可互换,活着定义为:
and from looking at the source for this, it is checking the Thread.isAlive()
method and adding those to the enumerable. From this I deduce that the terms 'active' and 'alive' are interchangeable and 'alive' is defined as:
如果它已经启动并且尚未死亡。
A thread is alive if it has been started and has not yet died.
这篇关于什么定义了“活动”线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!