• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic