Add volatile to methodNameMap and chainMap (#34)

Modify MethodUtil#methodNameMap and CtSph#chainMap: add `volatile` to keep in line with others
This commit is contained in:
yizhenqiang 2018-08-05 09:05:55 +08:00 committed by Eric Zhao
parent b2a3ef26a7
commit 8075232cdd
2 changed files with 2 additions and 2 deletions

View File

@ -48,7 +48,7 @@ public class CtSph implements Sph {
* Same resource({@link ResourceWrapper#equals(Object)}) will share the same * Same resource({@link ResourceWrapper#equals(Object)}) will share the same
* {@link ProcessorSlotChain}, no matter in which {@link Context}. * {@link ProcessorSlotChain}, no matter in which {@link Context}.
*/ */
private static Map<ResourceWrapper, ProcessorSlotChain> chainMap private static volatile Map<ResourceWrapper, ProcessorSlotChain> chainMap
= new HashMap<ResourceWrapper, ProcessorSlotChain>(); = new HashMap<ResourceWrapper, ProcessorSlotChain>();
private static final Object LOCK = new Object(); private static final Object LOCK = new Object();

View File

@ -29,7 +29,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/ */
public final class MethodUtil { public final class MethodUtil {
private static Map<Method, String> methodNameMap = new HashMap<Method, String>(); private static volatile Map<Method, String> methodNameMap = new HashMap<Method, String>();
private static final Object LOCK = new Object(); private static final Object LOCK = new Object();