// Copyright © 2017 DWANGO Co., Ltd.
package jp.co.dwango.cbb.db;

import java.util.ArrayList;
import java.util.List;

/**
 * 同一プロセス内で識別名付きのテキストデータを交換できるIPC
 */
public class MemoryQueue {
	private final List<MemoryQueueHandler> handlers = new ArrayList<MemoryQueueHandler>();

	public MemoryQueue() {
	}

	void addListener(MemoryQueueHandler handler) {
		handlers.add(handler);
	}

	void removeListener(MemoryQueueHandler handler) {
		handlers.remove(handler);
	}

	void send(String data) {
		for (MemoryQueueHandler handler : handlers) {
			handler.onReceive(data);
		}
	}
}

@@ -88,16 +88,46 @@
 ayList;%0A
+import java.util.Collections;%0A
 import j
@@ -262,16 +262,45 @@
 dlers = 
+Collections.synchronizedList(
 new Arra
@@ -326,16 +326,17 @@
 ndler%3E()
+)
 ;%0A%0A%09publ

make thread safe