Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6914 dpurdie 1
package com.erggroup.buildtool.daemon;
2
 
3
import java.util.Timer;
4
import java.util.TimerTask;
5
 
6
import org.apache.log4j.Logger;
7
 
8
/**Task scheduling template
9
 */
10
public class ResumeTimerTask
11
  extends TimerTask
12
{
13
  /**Logger
14
   * @attribute
15
   */
16
  private static final Logger mLogger = Logger.getLogger(ResumeTimerTask.class);
17
 
18
  /**initially false
19
   * true when cancelled
20
   * @attribute
21
   */
22
  private boolean mTimerCancelled = false;
23
 
24
  /**timer handle to cancel the Timer thread
25
   * @attribute
26
   */
27
  private Timer mTimer;
28
 
29
  /**constructor
30
   */
31
  ResumeTimerTask()
32
  {
33
    mLogger.debug("ResumeTimerTask");
34
  }
35
 
36
  /**notifies all threads waiting on this objects monitor
37
   */
38
  public void run()
39
  {
40
    synchronized(BuildThread.mSynchroniser)
41
    {
42
      mLogger.debug("run");
43
      // wake up all BuildThreads waiting on its monitor
44
      BuildThread.mSynchroniser.notifyAll();
45
      mTimer.cancel();
46
      mTimerCancelled = true;
47
    }
48
  }
49
 
50
  /**accessor
51
   */
52
  void setTimer(Timer timer)
53
  {
54
    mLogger.debug("setTimer");
55
    mTimer = timer;
56
    mTimerCancelled = false;
57
  }
58
 
59
  /** Indicates that the time is not active
60
   * @return true - Timer is not active, False - Timer has been set
61
   * 
62
   */
63
  boolean isCancelled()
64
  {
65
    mLogger.debug("isCancelled");
66
    mLogger.info("isCancelled returned " + mTimerCancelled);
67
    return mTimerCancelled;
68
  }
69
}