|
PenProfile 2.x | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.livescribe.util.InactivityTimer
public abstract class InactivityTimer
This class implements a timer thread that can be used to monitor
application activity. The abstract notifyNoActivity() method is
called when no activity is detected for a specified inactivity time.
The timer is started with the startTimer(long, long) or
startTimer(long) methods, and is stopped when there is either no
activity for the specified timeout or stopTimer() is called.
A timer instance can be used more than once. To reuse the instance, the
timer must be stopped. If the notifyNoActivity() or
notifyStopped() methods are called, then the timer will be
stopped. The isStopped() method can also be used to determine if
the timer is stopped ("not running").
One useful way to use this class is either as an inner or anonymous class.
| Constructor Summary | |
|---|---|
InactivityTimer()
Creates a new inactivity timer. |
|
| Method Summary | |
|---|---|
boolean |
isStopped()
Indicates if the timer is stopped. |
protected abstract void |
notifyNoActivity()
The method is called when there is no activity for the specified inactivity time. |
protected void |
notifyStopped()
This is called when the timer has been stopped or interrupted. |
void |
recordActivity()
This marks some activity at the current time and resets the timer's waiting period to be the initial inactivity time. |
void |
recordActivityIfRunning()
This atomically combines the check for the timer running with marking some activity. |
void |
run()
The timer thread code. |
void |
startTimer(long inactivityTime)
Starts the timer using the specified inactivity period. |
void |
startTimer(long lastActivityTime,
long inactivityTime)
Starts the timer. |
void |
stopTimer()
Stops the timer. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public InactivityTimer()
| Method Detail |
|---|
public void startTimer(long lastActivityTime,
long inactivityTime)
The timer is only started if it is not already running and if the inactivity time is greater than zero.
lastActivityTime - use this as the last time activity occurred,
in msinactivityTime - the inactivity period, in ms
java.lang.IllegalStateException - if the timer is already running.startTimer(long),
isStopped()public void startTimer(long inactivityTime)
notifyNoActivity() is called.
The timer is only started if it is not already running and if the inactivity time is greater than zero.
inactivityTime - the inactivity period, in ms
java.lang.IllegalStateException - if the timer is already running.notifyNoActivity(),
isStopped()public void stopTimer()
notifyStopped() will be called instead of
notifyNoActivity(). Simply call startTimer(long) to
restart the timer.
notifyStopped()public boolean isStopped()
notifyNoActivity() or
notifyStopped().
Note that this does not necessarily indicate whether the timer
has been stopped via stopTimer(). Rather, it is equivalent to
Is this timer not still running?
true if the timer is stopped and
false otherwise.public void run()
run in interface RunnableThread.run()protected abstract void notifyNoActivity()
notifyStopped() will not be called.
startTimer(long),
startTimer(long, long)protected void notifyStopped()
notifyNoActivity() will not be called.
public void recordActivity()
startTimer(long)public void recordActivityIfRunning()
isStopped() check and a recordActivity() call.
Please see recordActivity() for more information.
startTimer(long),
recordActivity(),
isStopped()
|
PenProfile 2.x | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||