本文介绍了java的线程安全映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个线程安全的地图,我有这样的事情:(我对java很新)
i need a thread safe map, i have something like this: (i'm very new to 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
}
}
推荐答案
这篇关于java的线程安全映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!