⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cachemanagerimpl.java

📁 JAVA Servlet2.3外文书籍源码
💻 JAVA
字号:
package cache;import java.util.HashMap;import java.util.Iterator;public final class CacheManagerImpl implements ICacheManager {        private static CacheManagerImpl mySelf;    private HashMap cacheMap = new HashMap();
    /** @link aggregation */
    /*#SimpleCacheImpl lnkSimpleCacheImpl;*/
        private CacheManagerImpl() {                Thread th = new Thread(new Runnable() {            public void run() {                try {                    Thread.sleep(60*1000);                }catch(InterruptedException ex) {                    throw new RuntimeException(ex.getMessage());                }                expire();            }        });        th.setPriority(th.MIN_PRIORITY);        th.start();            }        public static ICacheManager getInstance() {                if(mySelf == null) {            synchronized(ICacheManager.class) {                if(mySelf == null)                    mySelf = new CacheManagerImpl();            }        }                return mySelf;            }        public ICache getCache(String cacheName) {                synchronized(this) {            return (ICache)cacheMap.get(cacheName);        }            }        public void addCache(ICache cache) {                synchronized(this) {            cacheMap.put(cache.getName(), cache);        }            }        private void expire() {                synchronized(this) {            Iterator it = cacheMap.values().iterator();            while(it.hasNext())                ((ICache)it.next()).expire();        }            }                    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -