Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


where to use join method and explain with real time
senario?and programatical explenation also..



where to use join method and explain with real time senario?and programatical explenation also....

Answer / ashwin khandelwal

class DemoAlive extends Thread {
int value;

public DemoAlive(String str){
super(str);
value=0;
start();
}

public void run(){
try{
while (value < 5){
System.out.println(getName() + ": " + (value++));
Thread.sleep(250);
}
} catch (Exception e) {}
System.out.println("Exit from thread: " + getName());
}
}

public class DemoJoin{

public static void main(String[] args){
DemoAlive da = new DemoAlive("Thread a");
DemoAlive db = new DemoAlive("Thread b");
try{
System.out.println("Wait for the child threads to finish.");
da.join();

if (!da.isAlive())
System.out.println("Thread A not alive.");

db.join();

if (!db.isAlive())
System.out.println("Thread B not alive.");
} catch (Exception e) { }
System.out.println("Exit from Main Thread.");
}
}

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is the difference between a static and a non-static inner class in java programming?

0 Answers  


Explain the use of sublass in a java program?

0 Answers  


What is Exception handling in Java How do you handle run time errors please explain with an example

2 Answers   Mastek, TCS,


What does flag mean in java?

0 Answers  


What is the maximum size of a string in java?

0 Answers  


What is the purpose of the strictfp keyword?

0 Answers  


define System.out.println(); what is the meaning!

19 Answers   Accenture,


Why do we create threads in java?

0 Answers  


Can list contain null in java?

0 Answers  


Why are parameters used in functions?

0 Answers  


What is the reflection?

0 Answers  


Explain the difference between the Boolean & operator and the && operator?

1 Answers  


Categories