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:
@@ -131,21 +131,18 @@ public abstract class Interval
|
|||||||
*/
|
*/
|
||||||
protected class IntervalTask extends TimerTask
|
protected class IntervalTask extends TimerTask
|
||||||
{
|
{
|
||||||
{ // initializer
|
|
||||||
if (_runQueue != null) {
|
|
||||||
_runner = new Runnable() {
|
|
||||||
public void run () {
|
|
||||||
safelyExpire(IntervalTask.this);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void run () {
|
public void run () {
|
||||||
if (_runQueue == null) {
|
if (_runQueue == null) {
|
||||||
safelyExpire(this);
|
safelyExpire(this);
|
||||||
} else {
|
} else {
|
||||||
|
if (_runner == null) { // lazy initialize _runner
|
||||||
|
_runner = new Runnable() {
|
||||||
|
public void run () {
|
||||||
|
safelyExpire(IntervalTask.this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
_runQueue.postRunnable(_runner);
|
_runQueue.postRunnable(_runner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user