Some synchronized changes.

This commit is contained in:
MobiusDev
2016-04-30 20:04:02 +00:00
parent 15d263a788
commit b001087964
17 changed files with 127 additions and 492 deletions

View File

@@ -64,7 +64,7 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
private L2WorldRegion _worldRegion;
/** Instance type */
private InstanceType _instanceType = null;
private volatile Map<String, Object> _scripts;
private volatile Map<String, Object> _scripts = new ConcurrentHashMap<>();
/** X coordinate */
private final AtomicInteger _x = new AtomicInteger(0);
/** Y coordinate */
@@ -531,16 +531,6 @@ public abstract class L2Object extends ListenersContainer implements IIdentifiab
*/
public final <T> T addScript(T script)
{
if (_scripts == null)
{
synchronized (this)
{
if (_scripts == null)
{
_scripts = new ConcurrentHashMap<>();
}
}
}
_scripts.put(script.getClass().getName(), script);
return script;
}