Particular Thread Count

后端 未结 5 766
花落未央
花落未央 2021-01-24 01:11

I want to know how many active threads are there for a particular Thread class. Lets say I have a class T which extends thread. In some other class (Ex: Demo) , I want to get t

5条回答
  •  猫巷女王i
    2021-01-24 01:50

    Try to use ThreadPoolExecutor. You can extend the ThreadPoolExecutor and counts the number of threads by calling getActiveCount().

    http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html

提交回复
热议问题