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...

Write java code to print "Hello how are you"
Thread1 should have "Hello"
Thread2 should have "how are you"
both the threads should start at the same time

Answer Posted / bulu

// thread one to print "Hello"
class Thr1 extends Thread
{
public void run()
{
System.out.print("Hello ");
}
}

//thread two to print "how are you?"
class Thr2 extends Thread
{
public void run()
{
try{
Thread.sleep(1);
}
catch(InterruptedException e)
{
System.out.println("interrution occure");
}
System.out.println("How are you ?");
}
}

// main thread

public class BuluThread
{
public static void main(String ag[])
{
Thread t1=new Thr1();
Thread t2=new Thr2();

t2.start();
t1.start();
}
}


//file name should "BuluThread.java"

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we declare an array without size in java?

1024


What type of language is java?

1007


When can you say a graph to be a tree?

1087


What is void data type?

1001


Explain what is Marker interface?

1094


why java does not support unsigned keyword?

5268


Can we start a thread twice in java?

989


what is predefined function in java?

988


What is the purpose of the file class in java programming?

1031


State the significance of public, private, protected class?

1113


What is method overloading in java ?

1099


What is the difference between int and integer in java?

1038


How to perform linear search in java?

961


Explain an algorithm to find depth of a binary tree.

1048


What are the difference between composition and inheritance in java?

1035