by Anonymous » 17 Mar 2025, 00:28
Ich brauche eine Thread -Safe -Karte, ich habe so etwas: (Ich bin sehr neu in Java) < /p>
Code: Select all
public static class Manager
{
static
{
//something wrong here, doesn't compile
list = new java.util.Collections
.synchronizedMap(new Map());
}
static Map 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
}
}
Ich brauche eine Thread -Safe -Karte, ich habe so etwas: (Ich bin sehr neu in Java) < /p>
[code] public static class Manager
{
static
{
//something wrong here, doesn't compile
list = new java.util.Collections
.synchronizedMap(new Map());
}
static Map 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
}
}
[/code]