相关疑难解决方法(0)

java的线程安全映射

我需要一个线程安全的地图,我有这样的东西:(我对java很新)

 public static class Manager
        {
        static 
        {
//something wrong here, doesn't compile
           list = new java.util.Collections
          .synchronizedMap(new Map<String, Client>());
        }

       static Map<String,Client> list;

        public static void AddClient(Client client)
        {
        // thread safe add client to the list
        }

        public static void RemoveClient(Client client)
        {
        // thread safe remove client to the list
        }

        }
Run Code Online (Sandbox Code Playgroud)

java

42
推荐指数
3
解决办法
7万
查看次数

标签 统计

java ×1