List of usage examples for org.apache.commons.collections MapIterator remove
void remove();
Map
(optional operation). From source file:com.inbravo.scribe.rest.service.crm.cache.CRMSessionCache.java
public final void initialize() { if (cacheManager != null) { cacheManager.cancel();/*from w w w. ja va 2s . c om*/ } cacheManager = new Timer(true); cacheManager.schedule(new TimerTask() { public void run() { long now = System.currentTimeMillis(); try { MapIterator itr = cacheMap.mapIterator(); while (itr.hasNext()) { Object key = itr.next(); final CachedObject cobj = (CachedObject) itr.getValue(); if (cobj == null || cobj.hasExpired(now)) { if (logger.isDebugEnabled()) { logger.debug("----Inside CRMSessionCache: removing " + key + ": Idle time= " + (now - cobj.timeAccessedLast) + "; Stale time= " + (now - cobj.timeCached) + "; Object count in cache= " + cacheMap.size()); } itr.remove(); Thread.yield(); } } } catch (ConcurrentModificationException cme) { /* * This is just a timer cleaning up. It will catch up on cleaning next time it runs. */ if (logger.isDebugEnabled()) { logger.debug("----Inside CRMSessionCache:Ignorable ConcurrentModificationException"); } } } }, 0, tiv); }