@@ -0,0 +1,1349 @@
+package com.eblly.multiplePattern;%0A%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0A/**%0A * Multiton pattern%0A * %E6%83%85%E6%99%AF%EF%BC%9A%E7%95%B6%E9%80%A3%E6%8E%A5%E6%95%B8%E6%93%9A%E5%BA%AB%E6%99%82%EF%BC%8Csession%E6%9C%AA%E9%97%9C%E9%96%89%E6%99%82%E5%89%87%E6%87%89%E8%A9%B2%E7%B9%BC%E7%BA%8C%E4%BD%BF%E7%94%A8%E7%95%B6%E5%89%8Dsession%EF%BC%8C%E8%80%8C%E4%B8%8D%E5%89%87%E5%8F%A6%E5%A4%96%E5%89%B5%E5%BB%BA%EF%BC%8C%E9%80%99%E6%A8%A3%E5%8F%AF%E4%BB%A5%E6%8F%90%E9%AB%98%E6%80%A7%E8%83%BD%EF%BC%8C%E7%AF%80%E7%9C%81%E5%85%A7%E5%AD%98%E9%96%8B%E9%8A%B7%E3%80%82%0A *%0A * @author eblly%0A * @version 1.0%0A * @date Aug 12, 2015%0A **/%0Aclass SessionFactory %7B%0A    public static final Map%3CString, String%3E sessionMap = new HashMap%3C%3E();%0A%0A    /**%0A     * %E6%8E%A7%E5%88%B6%E4%BD%B5%E7%99%BC%EF%BC%8C%E9%82%84%E6%9C%89%E4%B8%80%E7%A8%AE%E6%98%AF%E4%BD%BF%E7%94%A8ConcurrentHashMap%0A     *%0A     * @param key%0A     * @return%0A     */%0A    public String getSession(String key) %7B%0A        synchronized (key) %7B%0A            String session = null;%0A            if ((session = sessionMap.get(key)) == null) %7B%0A                session = %22new Session%22;%0A                sessionMap.put(key, session);%0A            %7D%0A            return session;%0A        %7D%0A    %7D%0A%7D%0A%0Apublic class Main %7B%0A    public static void main(String%5B%5D args) %7B%0A        SessionFactory sessionFactory = new SessionFactory();%0A        sessionFactory.getSession(%22111%22);%0A        System.out.println(%22sessionMap size=:%22 + sessionFactory.sessionMap.size());%0A        System.out.println();%0A%0A        sessionFactory.getSession(%22111%22);%0A        System.out.println(%22sessionMap size=:%22 + sessionFactory.sessionMap.size());%0A        System.out.println();%0A%0A        sessionFactory.getSession(%22222%22);%0A        System.out.println(%22sessionMap size=:%22 + sessionFactory.sessionMap.size());%0A        System.out.println();%0A    %7D%0A%7D

add multiple pattern