• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to pause one thread and start another thread to get  RSS feed

 
Karn Kumar
Ranch Hand
Posts: 153
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one thread already running and it calls method

which returns the true/false variable and depending on that returned boolean variable i want to call another thread .

I want to pause the Parent thread for time till the second thread complete and then continue with the parent issue .
Is there any best way .
Please suggest .
Thanks in advance.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, If the Parent Thread does nothing but wait for he Child Thread to finish before continuing then you aren't running any code concurrently, which means you don't need threads. Why are you running the Child code in a separate Thread.why not just run it in the same Thread?
 
Maruthi Janardhan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you dont need another thread. If you want to do it just for some accessibility issue like in swing, this is the code you put in the parent thread:

 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maruthi Janardhan wrote:Yes you dont need another thread. If you want to do it just for some accessibility issue like in swing, this is the code you put in the parent thread:



We may be drifting off topic - but if you are using Swing and working in the event dispatcher thread, then you do not want to make the edt wait for the child task to complete. If this is your scenario you are best off using a callback mechanism (childThread does its work, then calls a method which gets executed on the edt). The easiest way to do that is use a SwingWorker.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!