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

Does chrome use java?

527


Can list have duplicates in java?

533


What is static synchronization?

581


Compare overloading and overriding?

563


What are static blocks and static initalizers in java ?

591






What does compareto () do in java?

582


What is the difference between super class & sub class?

573


Differentiate storage classes on the basis of their scope?

680


Are arrays primitive data types?

655


What is the final variable?

585


Why is the main method static?

612


What are the different conditional statements?

571


What do you understand by the bean persistent property?

571


What is entry in java?

541


How do you do math powers in java?

583