Mercurial > hg > blitz_stable
comparison src/org/dancres/blitz/stats/ThreadStat.java @ 0:3dc0c5604566
Initial checkin of blitz 2.0 fcs - no installer yet.
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sat, 21 Mar 2009 11:00:06 +0000 |
parents | |
children | 6f68e94c1fb8 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3dc0c5604566 |
---|---|
1 package org.dancres.blitz.stats; | |
2 | |
3 public class ThreadStat implements Stat, StatGenerator { | |
4 private long theId = StatGenerator.UNSET_ID; | |
5 private int theThreadCount = 0; | |
6 | |
7 ThreadStat() { | |
8 } | |
9 | |
10 ThreadStat(long anId, int aThreadCount) { | |
11 theId = anId; | |
12 theThreadCount = aThreadCount; | |
13 } | |
14 | |
15 public void setId(long anId) { | |
16 theId = anId; | |
17 } | |
18 | |
19 public long getId() { | |
20 return theId; | |
21 } | |
22 | |
23 public synchronized Stat generate() { | |
24 ThreadGroup myGroup = Thread.currentThread().getThreadGroup(); | |
25 | |
26 int myActiveCount = myGroup.activeCount(); | |
27 | |
28 while ((!myGroup.getName().equals("main")) && | |
29 (myGroup = myGroup.getParent()) != null) { | |
30 myActiveCount += myGroup.activeCount(); | |
31 } | |
32 | |
33 return new ThreadStat(theId, myActiveCount); | |
34 } | |
35 | |
36 public String toString() { | |
37 return "Thread count: " + theThreadCount; | |
38 } | |
39 } |