SWT, multiple threads, and exceptions
<p>I'm using SWT in a main GUI program.  Within it, I create another thread to run some programs.  However, if some errors are encountered in those processes, I want to report this to the user by making a message box appear.  Because in SWT, only a single thread can perform GUI operations, I was having the program runner throw exceptions, so the GUI thread could deal with them.  However, I am having problems because I create a new thread for the program runner (in order not to hold up the GUI thread, which will be continuously updating and refreshing some graphics), but as a result, the exceptions that take place are stuck as part of that thread, which can not create the error message box.  Any suggestions on how to deal with this?</p>

<pre class="lang-java prettyprint-override"><code>private void goButtonActionPerformed()
{
    // create the program runner object
    ProgramRunner PR = new ProgramRunner(); // real code passes in data to be used

    try{
        // check all necessary parameters are entered
        boolean paramsOK = PR.checkParams();
        if (paramsOK)
        {
            // all necessary information is available.  Start Processing.
            Thread t = new Thread() {
                public void run()
                {
                    try{
                        PR.runPrograms();
                    }
                    catch (IOException iox)
                    {
                        // This does not work to catch &amp; display the exceptions 
                        // which took place in PR.runPrograms(), because this 
                        // thread is not allowed to perform GUI operations.  
                        // However, I don't know how to pass this 
                        // exception / error notification out of this thread.
                        MessageBox mb = new MessageBox(m_Shell, SWT.ICON_ERROR);
                        mb.setMessage(iox.getMessage());
                        mb.open();
                    }
                }
            };
            t.start();
        }
    } 
    catch (IOException iox)
    {
        // this works to catch &amp; display the exceptions which took place 
        // in PR.checkParams() because that is not a separate thread
        MessageBox mb = new MessageBox(m_Shell, SWT.ICON_ERROR);
        mb.setMessage(iox.getMessage());
        mb.open();
    }
</code></pre>