Particular Thread Count

后端 未结 5 820
花落未央
花落未央 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条回答
  •  误落风尘
    2021-01-24 01:48

    You could implement ThreadFactory to construct the custom Thread classes and supply a ThreadGroup instance to get the counts from. By using ThreadFactory, each instance could contain its own ThreadGroup, making counts accessible based on the factory used.

提交回复
热议问题