I have to write a GUI application that uses RMI to keep consistent state across multiple clients.
Because the RMI calls will block, I put them in a separate thread from the GUI thread. To push information to and from the GUI thread my first thought was to use a synchronized buffer.
But if I call a synchronized method on the Buffer, the GUI will freeze. If I don't use the synchronized keyword the Buffer won't be thread safe.
From the Java Docs:
It is not possible for two invocations of synchronized methods on the same object to interleave. When one thread is executing a synchronized method for an object, all other threads that invoke synchronized methods for the same object block (suspend execution) until the first thread is done with the object.
Is there some other alternative that will make the buffer thread safe and not freeze the GUI.