DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2005
    Posts
    12

    passing exceptions from a thread

    could somebody tell me how to pass an exception from a thread to its parent class? like i want to do this.

    class someClass {
    void someMethod throws Exception () {
    throw new Exception();
    }
    }

    class anotherClass implements Runnable {
    public void run () {
    someClass s = new someClass();
    s.someMethod();
    }
    }

    its not gonna compile because i've got to try catch s.someMethod(). But i dont want to catch it just then, i want the error to pass to its parent class, which in my case is a gui class to display the error. anybody have ideas on how?

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    Parent class ? What exactly do you mean, If you want the error to be "passed" then
    it must be up the calling stack ot by a pointer value.
    eschew obfuscation

  3. #3
    Join Date
    May 2005
    Posts
    12
    yea what i meant was the calling stack. how do i send the error up the calling stack so i wont have to handle it in the run() method?

  4. #4
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    The run method, when used as target for a runnable, is not part of your programs
    regular calling stack, its the java VM that doing the calling.

    How come your program/strategy can't handle an exception thrown by a
    thread ? I have a feeling that you may be "barking up the wrong tree"
    Last edited by sjalle; 06-04-2005 at 10:34 AM.
    eschew obfuscation

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links