• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

What happens when a running thread calls join?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I read that when a thread calls join, it makes the currently running thread join after it. Please correct me if i am wrong here.

Now what happens if innocently the thread that is currently running calls join()?

I believe the scenario would roughly translate to "Thread.currentThread().join();"

I tried this in eclipse out of curiosity and it seems to me like the VM hung or something. There was a process running but i couldnt see anything on the console

If this is the case wouldnt it lead to catastrophic results in case in an application only one thread happens to be running at some point and it calls join()


Cheers
 
author
Posts: 23923
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mahanth Kumar wrote:
If this is the case wouldnt it lead to catastrophic results in case in an application only one thread happens to be running at some point and it calls join()



Yea... I guess. But wouldn't it also be "catastrophic". if you call the System.exit() method when you didn't mean to? Having a thread wait for itself to finish, is simply a bug, and it is probably as bad as any other bug.

Henry
reply
    Bookmark Topic Watch Topic
  • New Topic