Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

joins

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what exactly join does?
in multithreading?
if possible give small example with explanation?

thank u
 
Ranch Hand
Posts: 3143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to move this to Java in General (intermediate) where I think it is more appropriate.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi rohan,
when u give join statment parent thread wait till child thread is completed.
Go thru following code and observe the output and then observe the output by comment the join
class Threadtest extends Thread
{
Thread t;
public static void main(String[] args)
{
System.out.println("main thread started");
Threadtest tt = new Threadtest();
tt.start();
System.out.println("Reach before joined");
try
{
tt.join();
}
catch (Exception e)
{
System.out.println("error in join");
}
System.out.println("Reach after joined");
}
public void run()
{
System.out.println("Started new Thread ");
for(int i = 1 ; i<5 ; i++)
{
try
{
sleep(100);
System.out.println("I increamented to "+ i);
}
catch(Exception e)
{
System.out.println("error in sleep");
}
}
}
}

[This message has been edited by Praveen Jadhav (edited January 03, 2001).]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic