Java is it wise to use an inner thread? if yes how to extract exceptions?
<p>atm I am using an inner thread for calling a method. This method can throw an Exception. Is there a way to receive the Exception in the outer class to react to it?
Or should I go with writing a "workthread" and adding an observer to it? </p>

<p>I implemented an MVC-Pattern. This this method is called in my model. Now I want to display an msg about the exception. Therefore I need to know the exception. </p>

<pre><code>public void startServer(final String path, final int port, final double speedup) {

    serverIsStopped = false;

    new Thread() {

        public void run() {
            server = new SWTimeServer();
            try{
                server.startServer(port, speedup, path);
            }catch (ClientDisconnectedException e) {
                serverIsStopped = true;
                //TODO
            } catch (ParseException e) {
                serverIsStopped = true;     
                //TODO
            }
        }
    }.start();


}
</code></pre>

<p>I came up with this quick solution. But  pretty ugly. Your opinions?</p>

<pre><code>private boolean serverIsStopped = true;
private Model model = this;

public void startServer(final String path, final int port, final double speedup) {

    serverIsStopped = false;

    new Thread() {

        public void run() {
            server = new SWTimeServer();
            try{
                server.startServer(port, speedup, path);
            }catch (ClientDisconnectedException e) {
                serverIsStopped = true;
                model.notifyObservers(e);
            } catch (ParseException e) {
                serverIsStopped = true;     
                model.notifyObservers(e);
            }
        }
    }.start();


}
</code></pre>

<p>Thanks for answers</p>

<p>Greetings
Tarken</p>
