if (size > maxCount)
{
List excess = fTestRunSessions.subList(maxCount, size);
for (Iterator iter = excess.iterator(); iter.hasNext(); )
{
TestRunSession oldSession = (TestRunSession) iter.next();
if (!(oldSession.isStarting() || oldSession.isRunning() || oldSession.isKeptAlive()))
{
toRemove.add(oldSession);
iter.remove();
}
}
}
}
for (int i = 0; i < toRemove.size(); i++)
{
TestRunSession oldSession = (TestRunSession) toRemove.get(i);
notifyTestRunSessionRemoved(oldSession);
}
notifyTestRunSessionAdded(testRunSession);
}