Lazy-create the Runnable that expires us on the RunQueue.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@1567 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
ray
2005-01-07 22:51:04 +00:00
parent a6eb8ef8d7
commit a100b234ab
@@ -131,21 +131,18 @@ public abstract class Interval
*/ */
protected class IntervalTask extends TimerTask protected class IntervalTask extends TimerTask
{ {
{ // initializer // documentation inherited
if (_runQueue != null) { public void run () {
if (_runQueue == null) {
safelyExpire(this);
} else {
if (_runner == null) { // lazy initialize _runner
_runner = new Runnable() { _runner = new Runnable() {
public void run () { public void run () {
safelyExpire(IntervalTask.this); safelyExpire(IntervalTask.this);
} }
}; };
} }
}
// documentation inherited
public void run () {
if (_runQueue == null) {
safelyExpire(this);
} else {
_runQueue.postRunnable(_runner); _runQueue.postRunnable(_runner);
} }
} }