| Method from org.apache.tomcat.util.threads.Reaper Detail: |
public int addCallback(ThreadPoolRunnable c,
int interval) {
synchronized (lock) {
cbacks[count] = c;
count++;
return count - 1;
}
}
|
public long getDefaultIntervale() {
return interval;
}
|
public void removeCallback(int idx) {
synchronized (lock) {
count--;
cbacks[idx] = cbacks[count];
cbacks[count] = null;
}
}
|
public void run() {
while (running) {
if (!running)
break;
try {
Thread.sleep(interval);
} catch (InterruptedException ie) {
// sometimes will happen
}
if (!running)
break;
for (int i = 0; i < count; i++) {
ThreadPoolRunnable callB = cbacks[i];
// it may be null if a callback is removed.
// I think the code is correct
if (callB != null) {
callB.runIt(tdata[i]);
}
if (!running)
break;
}
}
}
|
public void setDefaultInterval(long t) {
// XXX Should be called 'interval' not defaultInterval
interval = t;
}
|
public void startReaper() {
running = true;
this.start();
}
|
public synchronized void stopReaper() {
running = false;
if (log.isDebugEnabled())
log.debug("Stop reaper ");
this.interrupt(); // notify() doesn't stop sleep
}
|