JDataStore, threads, Swing, and deadlock.

Abstract: JDataStore, threads, Swing, and deadlock.

  Is there a deadlock risk when you have a thread that updates visual data displayed on a Swing component?

Yes, there is. Swing components can be accessed only by one thread at a time.

For example, the code snippet below calls a thread that updates a JdbTable. This will most probably fail:
    public void refreshQueries(){
        Thread t=new Thread(new TRefreshQuery1());
        t.start();
    }
To have your runnable object put on a queue and be correctly dispatched to the Swing event thread modify the code as follows:
   public void refreshQueries(){
       try {
           Thread t=new Thread(new TRefreshQuery1());
           javax.swing.SwingUtilities.invokeLater(t);
       }
       catch(Exception ex) {
           ex.printStackTrace();
       }
   }
For more information about the use of Threads with Swing refer to this article on java.sun.com.