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 / ratan kumar

class ThreadTest1 implements Runnable
{
public void run()
{
System.out.print("Hello ");
}
}
class ThreadTest2 implements Runnable
{
public void run()
{
System.out.print("How are You");
}
}
public class Test {

/**
* @param args the command line arguments
*/
public static void main(String[] args) throws InterruptedException {
Runnable r1=new ThreadTest1();
Runnable r2=new ThreadTest2();
Thread t1=new Thread(r1);
Thread t2=new Thread(r2);
t1.start();
t2.start();

t1.join();
t2.join();
}

}

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Addition to previous section relative word 5th one was Putrid ans: rotten, also there was prob. in 1st section on bucket weight ans:10kg, also there was a prob. on train speed to find bridge length ans:800 mtrs.

2110


What is struts in java?

987


What are keyboard events?

1094


How can we pass argument to a function by reference instead of pass by value?

1044


Under what conditions is an object’s finalize() method invoked by the garbage collector?

977


Can I overload to string method

1388


Which eclipse is best for java?

957


How to implement an arraylist in java?

1040


What are the topics in core java?

1001


Can a final variable be initialized in constructor?

925


How to implement a multithreaded applet?

2608


Does a function need a return?

915


What is not object oriented programming?

873


Why webdriver is an interface?

993


What's the difference between int and integer in java?

1094