Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6064419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:16:42+00:00 2026-05-23T09:16:42+00:00

atm I am using an inner thread for calling a method. This method can

  • 0

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?

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.

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();


}

I came up with this quick solution. But pretty ugly. Your opinions?

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();


}

Thanks for answers

Greetings
Tarken

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:16:42+00:00Added an answer on May 23, 2026 at 9:16 am

    You can’t receive an exception from Thread A from Thread B with any sort of basic try/catch structure that’d you’d normally use. You’ll have to implement some type inter-thread messaging/signaling if you want to do something like that.

    Beyond that advice, there’s not much help I can give without a more complete explanation of what exactly you’re trying to do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way finding largest container inside a container using STL? ATM, I
ATM i cant quiet imagine how this will work. I'm sure it can be
I can only think of Peek() and ReadNoAdvance() atm, but I wonder if there
atm i'm using this code, but this code doesn't works for me, because the
This project is a basic ATM program. I'm using a file to store all
I'm working on a bigger project atm, but I made this simple example to
Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)
I was wondering if anyone had a better idea how to do this. atm
I have a managed class that uses a COM that looks like this. Public
Im using the Prototype Javascript Library's Window class to create pop up windows in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.