This week's book giveaway is in the Java in General forum. We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line! See this thread for details.
In our open source application we have a few(many) model classes driving the UI panels. Currently, we take the approach of allowing the models to be fully unsynchronized and making sure that we touch/read/modify these models from within the event thread.
So, when constructing/spawning a worker thread, the required values from the model are passed into the constructor of the worker thread before running it. After it finished, we use invokeLater to process the worker results back into the models. This works only for simple values, such as a String. But it won't work for unsynchronized collections, unless the whole collection is cloned. As the application grow larger, thread safety become more of an concern and I find the need to apply synchronization to part of the models as needed.
Suppose I change the paradigm to create fully thread safe UI models in the first place, will I run into dead lock issues? Is this a better approach?