title: Event Dispatch Thread painting
body: <p>Just a quick one - I'm in the process of writing a Sega Master System emulator. The design thus far is that the GUI (JFrame subclass etc.) runs in the Event Dispatch Thread, via an EventQueue.invokeLater() call, and all the emulator functions run in a separate thread. From what I understand this is supposed to be good practice, as the EDT is supposed to initialise and update the GUI, with Swing not being thread-safe.</p>
  
  <p>This leads me to a small question - the console runs in the separate thread (Z80, VDP, etc.) and the VDP (when I've finished it) will update a BufferedImage. As long as I mark this BufferedImage as 'synchronized', is it safe to then access it from the EDT (the GUI's paint method in particular)? I ask this as otherwise I will have to put a lot of VDP logic into the paint method itself, and I'd rather not do this, as it will slow down the GUI overall.</p>
  
  <p>Simple question I know, but I'm still getting used to pushing Java2D for decent speed animation. It is worth mentioning that right after the repaint() method is called in the logic thread, the logic thread will sleep until woken for the next frame pass, so I'm guessing there won't be a performance hit from this design - am I right?</p>
  
  <p>Many thanks,
  Phil Potter</p>
  
  <p><em>UPDATE</em> I should have used better language - the VDP will be accessing the BufferedImage through a synchronized setter method and the EDT will be accessing it through a synchronized getter method.</p>