long now = _clock.getTime();
long allowed = now - maxIdleTime;
TimeStampedSoftDListNode tsNode = null;
FastStack stack = new FastStack();
synchronized (super.collection) {
Object done = null;
while (done == null) {
tsNode = (TimeStampedSoftDListNode) list.getFirstDListNode();
if (tsNode == null) { //Empty list
done = new Object();
} else if (tsNode.timeStamp <= allowed) {
//Need to destroy the contained object
list.delink(tsNode);
stack.push(tsNode.object);
killedCount++;
} else {
//This node is not old enough
done = new Object();
}
} //End of for loop
super.createdCount -= killedCount;
int deficit = list.size() - minSize;
super.preload(0 - deficit);
if (killedCount == 0) {
} else if (killedCount == 1) {
collection.notify();
} else {
collection.notifyAll();
}
} // end of synchronized
//Now destroy all collected objects
while (! stack.isEmpty()) {
Object object = stack.pop();
beforeDestroy(object);
factory.destroy(object);
}
//Bug 4677074 System.out.println("Leaving service after killing " + killedCount + " (idle) objects. Now size: " + list.size());