先上代码
package com.zte.iptv.global;
import javax.servlet.http.HttpSession;
import java.util.*;
public class MyHashMap<K,V> extends AbstractMap<K,V> {
private static volatile MyHashMap instance;
private int length = 16;
private boolean singleMode = true; //默认是0,支持单点登录;值为1时,一个session最多支持3个终端登录
Node<K, V>[] table = (Node<K, V>[]) new Node[length];
private MyHashMap(){
for(int i=0; i<length; i++) {
table[i] = new Node(0);
}
};
public static MyHashMap getInstance() {
if (instance == null) {
synchronized(new Object()) {
if (instance == null) {
instance = new MyHashMap();
}
}
}
return instance;
}
public void put(String key, Object value) {
int index = hash(key) & 15;