com.atlassian.bamboo.utils
Class Timer

java.lang.Object
  extended by java.lang.Thread
      extended by com.atlassian.bamboo.utils.Timer
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
BuildTimeoutKiller

public abstract class Timer
extends java.lang.Thread

This allows graceful timeouts to time consuming tasks (such as sending emails).


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Timer(long lengthOfTimeoutInMillis)
          Creates a timer of a specified lengthOfTimeoutInMillis
 
Method Summary
 void cancel()
           
abstract  void onTimeout()
          This callback is triggered if the timer times-out
 void restart()
          Resets the timer back to zero
 void run()
          Performs timer specific code
 void start()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Timer

public Timer(long lengthOfTimeoutInMillis)
Creates a timer of a specified lengthOfTimeoutInMillis

Parameters:
lengthOfTimeoutInMillis - Length of time before a onTimeout occurs
Method Detail

start

public void start()
Overrides:
start in class java.lang.Thread

cancel

public void cancel()

restart

public void restart()
Resets the timer back to zero


run

public void run()
Performs timer specific code

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

onTimeout

public abstract void onTimeout()
This callback is triggered if the timer times-out



Copyright © 2010 Atlassian. All Rights Reserved.