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
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.
What is struts in java?
What are keyboard events?
How can we pass argument to a function by reference instead of pass by value?
Under what conditions is an object’s finalize() method invoked by the garbage collector?
Can I overload to string method
Which eclipse is best for java?
How to implement an arraylist in java?
What are the topics in core java?
Can a final variable be initialized in constructor?
How to implement a multithreaded applet?
Does a function need a return?
What is not object oriented programming?
Why webdriver is an interface?
What's the difference between int and integer in java?