isActive是Thread的方法,莫非要我遍历?开销太大了:(

解决方案 »

  1.   

    ThreadGroup.activeCount() 
    Returns an estimate of the number of active threads in this thread group.
    这个方法是把sleep的Thread也算在内的。你只能对每个Thread做手脚了,定义一个runningSize,Thread在运行的时候runningSize++,在sleep()之前runningSize--.
      

  2.   

    sleep的thread的isActive,返回值也是true。
    看看,JAVA Doc:
    isAlive
    public final boolean isAlive()
    Tests if this thread is alive. A thread is alive if it has been started and has not yet died. Returns:
    true if this thread is alive; false otherwise.
      

  3.   

    不会别的方法,也是觉得只能用chubbchubb(长街)的方法了,希望有高手给出更快的方法
      

  4.   

    线程sleep的时候是什么状态?
      

  5.   

    线程sleep的时候是什么状态?