01: package org.jzonic.jlo;
02:
03: public class TimeTracker {
04:
05: private static ThreadLocal trackers = new ThreadLocal();
06:
07: public static void start() {
08: TimeTrackerObject tto = (TimeTrackerObject) trackers.get();
09: if (tto == null) {
10: tto = new TimeTrackerObject();
11: }
12: trackers.set(tto);
13: }
14:
15: public static void stop() {
16: trackers.set(null);
17: }
18:
19: public static long getEllapsedTime() {
20: TimeTrackerObject tto = (TimeTrackerObject) trackers.get();
21: if (tto != null) {
22: return tto.getEllapsedTime();
23: }
24: return 0;
25: }
26:
27: public static boolean isTracking() {
28: TimeTrackerObject tto = (TimeTrackerObject) trackers.get();
29: if (tto != null) {
30: return true;
31: }
32: return false;
33: }
34:
35: public static TimeTrackerObject get() {
36: return (TimeTrackerObject) trackers.get();
37: }
38:
39: }
|