Code example for CopyOnWriteArraySet

0
 
@SuppressWarnings("serial") 
public class BackgammonWebSocketServlet extends WebSocketServlet{ 
 
	public static final Set<BackgammonWebSocket> members = new CopyOnWriteArraySet<BackgammonWebSocket>(); 
    public static final Set<LinkedBlockingQueue<Webpackage>> queues = new CopyOnWriteArraySet<LinkedBlockingQueue<Webpackage>>(); 
	public static final LinkedBlockingQueue<Webpackage> outgoing = new LinkedBlockingQueue<Webpackage>(); 
     
     
    public BackgammonWebSocketServlet() throws InterruptedException { 
    	new Sender(outgoing).start(); 
    	queues.add(outgoing); 
    } 
 
 
	@Override 
	public WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) { 
		BackgammonWebSocket socket = new BackgammonWebSocket(members); 
		return socket; 
	} 
}