I am using JAVA Swings for a while. But never understood clearly the threading issues with it.
Just knew that SwingUtilities.invokeLater will avoid hanging of the application by some means of exceuting in a non-EDT thread (please correct me if i'm wrong).
How shall I handle concurrency inside Event Dispatch Thread. Since most of the functionality is handled inside action listeners, my application hangs everytime even if I launch the application using invokeLater method. I am handling db calls from a method inside action listeners.
Is there any improved way of handling concurrency for Swings in JAVA 7? What am I missing to do in my code? I have read few forums on this topic but never actually understood what needs to be done for concurrency in Swings.
I'd like to point you to the SwingWorker class. Here's an excerpt from the javadoc:
SwingWorker is designed for situations where you need to have a long running task run in a background thread and provide updates to the UI either when done, or while processing.
Code that handles creation of the GUI or interactivity with the GUI are handled within the Event Dispatch Thread (EDT). Anything else should be handled in a separated thread. The SwingWorker class
assists you in doing exactly this thing. It also provides a way to inform your Swing UI if the process has been finished (See SwingWorker.done()) . Try to read the javadoc of the class, there are also samples noted for this case.