SINTEF-9012 / bglib

Java implementation of the BGAPI binary protocol for Bluegiga BLE112 Bluetooth low energy modules.
37 stars 14 forks source link

Synchronize listeners #11

Closed rasendubi closed 9 years ago

rasendubi commented 9 years ago

Currently listeners list is not synchronized. That means that removing listener in receive handler causes ConcurrentModificationException to be thrown.

This patch wraps listeners list with Collections.synchronizedList() and synchronizes all iteration on it with synchronize(listeners) as synchornized list requires.

After that it's Ok to unsubscribe from events in receive handlers.