• Post Reply Bookmark Topic Watch Topic
  • New Topic

Please help me solve this  RSS feed

 
Renjith Mohan
Ranch Hand
Posts: 65
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Parent thread run indefinitely when started. I want to stop/wait the parent thread from the child thread. For that, I used the same thread instance of class Parent. However, it is not working.

Please help me figure it out

Thanks in advance,
jith
 
Rory Evans
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you have misunderstood how the wait() method works. Calling wait() on ANY object has the same affect - it causes the CURRENTLY running thread to wait. It looks to me like you're expecting the Parent Thread to wait simply because you have called p.wait().

This is not the case. You could call String.wait() and it would still have the same affect (the wait() method is part of Object - not Thread).

With this in mind, re-examine your code.
 
Renjith Mohan
Ranch Hand
Posts: 65
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Thanks Rory
I was able to execute the code.
 
Devaka Cooray
Marshal
Posts: 5517
688
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Renjith,
Please UseAMeaningfulSubjectLine instead of something like "Please help me solve this" when you post a question.
 
Renjith Mohan
Ranch Hand
Posts: 65
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Devaka,
I keep that in mind from now on.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!