aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Thread start Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Thread start" Watch "Thread start" New topic
Author

Thread start

Saibabaa Pragada
Ranch Hand

Joined: Oct 24, 2010
Posts: 162
Hi, Why I am getting Runtime Exception as given below.
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3647
    
  17

You are getting a runtime exception because you can start the thread only once. You are starting the same thread, because the getInst() method returns the same (static) Thread, regardless of what object you call it on.

The reason you are getting a stack overflow error, is because if you remove the static modifier, when the tr member is initialized, that new member will also initialize it's internal tr reference, which in turn will initialize it's initial reference, etc, etc, ad infinitum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread start