Add thread-safety support to the Hazelcast-based notification framework.

Change-Id: I606f6ccb417c733903b7d8305d8d23b434417c2e
diff --git a/src/main/java/net/onrc/onos/datagrid/HazelcastDatagrid.java b/src/main/java/net/onrc/onos/datagrid/HazelcastDatagrid.java
index b240299..8d797e7 100755
--- a/src/main/java/net/onrc/onos/datagrid/HazelcastDatagrid.java
+++ b/src/main/java/net/onrc/onos/datagrid/HazelcastDatagrid.java
@@ -762,8 +762,9 @@
      * @param typeV the type of the Value in the Key-Value store.
      * @return the event channel for the channel name.
      */
-    private <K, V> IEventChannel<K, V> createChannelImpl(String channelName,
-					     Class<K> typeK, Class<V> typeV) {
+    private synchronized <K, V> IEventChannel<K, V> createChannelImpl(
+					String channelName,
+					Class<K> typeK, Class<V> typeV) {
 	IEventChannel<K, V> castedEventChannel;
 	IEventChannel<?, ?> genericEventChannel =
 	    eventChannels.get(channelName);
diff --git a/src/main/java/net/onrc/onos/datagrid/HazelcastEventChannel.java b/src/main/java/net/onrc/onos/datagrid/HazelcastEventChannel.java
index b453139..7739e83 100644
--- a/src/main/java/net/onrc/onos/datagrid/HazelcastEventChannel.java
+++ b/src/main/java/net/onrc/onos/datagrid/HazelcastEventChannel.java
@@ -1,12 +1,11 @@
 package net.onrc.onos.datagrid;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.LinkedList;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import com.esotericsoftware.kryo.Kryo;
 import com.esotericsoftware.kryo.io.Input;
@@ -27,8 +26,9 @@
     private Class<?> typeK;			// The class type of the key
     private Class<?> typeV;			// The class type of the value
     private IMap<K, byte[]> channelMap = null;	// The Hazelcast channel map
-    private List<IEventChannelListener<K, V>> listeners = // Channel listeners
-	new ArrayList<IEventChannelListener<K, V>>();
+    // The channel listeners
+    private CopyOnWriteArrayList<IEventChannelListener<K, V>> listeners =
+	new CopyOnWriteArrayList<IEventChannelListener<K, V>>();
 
     // The map entry listener
     private MapEntryListener mapEntryListener = new MapEntryListener<K>();