1 package org.sapia.ubik.rmi.server.perf; 2 3 4 12 public class Topic implements Comparable { 13 private static int _count = 0; 14 private String _name; 15 private long _startTime = -1; 16 private long _endTime = -1; 17 private int _id; 18 19 22 public Topic(String name) { 23 _name = name; 24 _id = inc(); 25 } 26 27 public String getName() { 28 return _name; 29 } 30 31 public void start() { 32 _startTime = System.currentTimeMillis(); 33 } 34 35 public void end() { 36 _endTime = System.currentTimeMillis(); 37 } 38 39 public synchronized long duration() { 40 if ((_startTime == -1) || (_endTime == -1)) { 41 return -1; 42 } else { 43 long toReturn = _endTime - _startTime; 44 _startTime = -1; 45 _endTime = -1; 46 47 return toReturn; 48 } 49 } 50 51 54 public int compareTo(Object other) { 55 return _id - ((Topic) other)._id; 56 } 57 58 static synchronized int inc() { 59 return _count++; 60 } 61 } 62 | Popular Tags |