• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread start

 
Saibabaa Pragada
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.
 
Stephan van Hulst
Bartender
Pie
Posts: 5590
55
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic