java: Use CopyOnWriteArrayList instead of ArrayList for listener lists

This avoids ConcurrentModificationException if the callback thread
iterates a listener list while another thread adds/removes listeners
to/from this list.
shell: Handle special chars in item separator