• Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread start  RSS feed

 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Why I am getting Runtime Exception as given below.
 
Saloon Keeper
Posts: 8911
167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Willie Smits increased rainfall 25% in three years by planting trees. Tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!