i need a thread safe map, i have something like this: (i\'m very new to java)
public static class Manager
{
static
{
//something wr
Your code should look like this, ignoring imports, et al.
public class Manager
{
Map list = java.util.Collections.synchronizedMap(new HashMap());
public void AddClient(Client client)
{
// thread safe add client to the list
}
public void RemoveClient(Client client)
{
// thread safe remove client to the list
}
}
That said, beware that this is not as thread safe as you might hope. As others have mentioned, you probably want to use the Java Concurrent Collections.