So my program is a version of paint.
It creates a canvas and allows me to paint over the canvas with my mouse by getting Point's from the mouse using a HashSet and Iterator.
It also connects to another identical program via a DatagramSocket and sends the Point's it generates to the other program which displays this on it's canvas.
To do this I use a Runnable thread that listens for incoming Point's and adds them to the HashSet.
My problem is that i get java.util.ConcurrentModificationException because I add Point's to the HashSet from the connected program via the thread while painting. 
I don't see how to get around this exception since I want the canvas to update live.
solved this using a CopyOnWriteArraySet with which I could simply replace my HashSet :) thx for all your support!
 
     
    