01: package tide.threadanalysis;
02:
03: /** An item from the stack.
04: */
05: public final class StackItem {
06: final private StackTraceElement si;
07:
08: // first appear (relative time)
09: final private long created;
10: // last appear
11: private long end;
12: private final Thread.State state;
13:
14: public StackItem(StackTraceElement si, Thread.State state, long t0) {
15: this .created = System.nanoTime() - t0;
16: this .end = created;
17: this .si = si;
18: this .state = state;
19: }
20:
21: public final void setEnd(long a, long t0) {
22: this .end = a - t0;
23: }
24:
25: public final long getCreated() {
26: return created;
27: }
28:
29: public final long getEnd() {
30: return end;
31: }
32:
33: public final Thread.State getState() {
34: return state;
35: }
36:
37: public boolean isSameElement(final StackTraceElement si2) {
38: return si.toString().equals(si2.toString());
39: }
40:
41: @Override
42: public final String toString() {
43: StringBuilder sb = new StringBuilder();
44: long dt = end - created;
45: if (dt > 0) {
46: sb.append("" + si + " (" + created + "-" + end + ")");
47: } else {
48: sb.append("" + si + " (" + created + ")");
49: }
50: sb.append(", " + state);
51:
52: return sb.toString();
53: }
54:
55: }
|