Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

blocking the main() thread ( keeping it alive) til the background thread completes  RSS feed

 
Asif Kadiwala
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I want to block the main thread(keeping) it alive till the another (b/g) thead completes its execution, I want this scenario because my futher operations in the main() thread depends on the results of the b/g tread. I used the wait() in the main thread and notify in the another but could not solve my problem.

public static void main(String[] str) {

xxxx
xxxx
Thread t;
wait();
yyyy;
yyyy;
}

here all "yyyy" depends on the result of Thread t. So I want to block the main thread there.

Is there any way to accomplish this?? Thanks in advance.


Regards,

Asif
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
join() is the way to go.

Asif wrote: I used the wait() in the main thread and notify in the another but could not solve my problem.


TellTheDetails. Saying "could not solve" and "does not work" does not help. Show us the code that did not work.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!