I found the following snippet of code in luaj, and I began to doubt that if there is a chance that the changes made Mapafter it was created, it may not be visible to other threads, since there is no synchronization.
I know that since it is Mapdeclared final, its initialized values after building are visible to other threads, but what about the changes that will happen after that.
Some may also realize that this class is not thread safe, since calling coerce in a multi-threaded environment may even cause an infinite loop in HashMap, but my question is not that.
public class CoerceJavaToLua {
static final Map COERCIONS = new HashMap();
public static LuaValue coerce(Object paramObject) {
...;
if (localCoercion == null) {
localCoercion = ...;
COERCIONS.put(localClass, localCoercion);
}
return ...;
}
...
}