package com.zy.core.network; import com.zy.core.ThreadHandler; import com.zy.core.enums.SlaveType; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class DeviceConnectPool { private static final String _LINK = "_"; private static final Map conContain = new ConcurrentHashMap<>(); public static void put(SlaveType type, Integer id, ThreadHandler thread) { String key = toKey(type, id); remove(type, id); conContain.put(key, thread); } public static ThreadHandler get(SlaveType type, Integer id) { return conContain.get(toKey(type, id)); } public static void remove(SlaveType type, Integer id) { Object object = get(type, id); if (null == object) { return; } conContain.remove(toKey(type, id)); } private static String toKey(SlaveType type, Integer id){ return type.toString() + _LINK + id; } }