Class ElapsedTime

java.lang.Object
org.jboss.as.server.ElapsedTime

public final class ElapsedTime extends Object
Tracks elapsed time since either JVM start or a moment of initialization. The start point for the calculation can be 'reset', allowing the calculation provided by an instance to account for a conceptual 'restart'.
  • Method Details

    • startingFromJvmStart

      public static ElapsedTime startingFromJvmStart()
      Creates a tracker that tracks elapsed time since JVM start.
      Returns:
      the tracker. Will not return null.
    • startingFromNow

      public static ElapsedTime startingFromNow()
      Creates a tracker that tracks elapsed time since the invocation of this method.
      Returns:
      the tracker. Will not return null.
    • getStartTime

      public long getStartTime()
      Gets the tracker's start point.
      Returns:
      the start point for this tracker, in milliseconds since the epoch.
    • getElapsedTime

      public long getElapsedTime()
      Get the elapsed time in milliseconds since this tracker's start point.
      Returns:
      the elapsed time
    • reset

      public void reset()
      Reset this tracker to begin tracking from the JVM start time. Any ElapsedTime objects that were returned from this object's checkpoint() method will also be reset. Meant for cases where the 'origin' moment may have changed and this tracker should be updated accordingly -- for example, in a 'restored' JVM that supports some form of checkpoint and restore behavior.
    • checkpoint

      public ElapsedTime checkpoint()
      Create an ElapsedTime that tracks elapsed time from the current time, but whose starting point will automatically be reset if this object is reset.