Answer Posted / nachiyappan
class NewThread4 implements Runnable {
String name; // name of thread
Thread t;
NewThread4(String threadname) {
name = threadname;
t = new Thread(this, name);
System.out.println("New thread: " + t);
t.start(); // Start the thread
}
// This is the entry point for thread.
public void run() {
try {
for (int i = 5; i > 0; i--) {
System.out.println(name + ": " + i);
Thread.sleep(1000);
}
} catch (InterruptedException e) {
System.out.println(name + " interrupted.");
}
System.out.println(name + " exiting.");
}
}
class DemoJoin
{
public static void main(String args[])
{
NewThread4 ob1 = new NewThread4("One");
NewThread4 ob2 = new NewThread4("Two");
NewThread4 ob3 = new NewThread4("Three");
System.out.println("Thread One is alive: " +
ob1.t.isAlive());
System.out.println("Thread Two is alive: " +
ob2.t.isAlive());
System.out.println("Thread Three is alive: " +
ob3.t.isAlive());
// wait for threads to finish
try {
System.out.println("Waiting for threads to
finish.");
ob1.t.join();
ob2.t.join();
ob3.t.join();
} catch (InterruptedException e)
{
System.out.println("Main thread Interrupted");
}
System.out.println("Thread One is alive: " +
ob1.t.isAlive());
System.out.println("Thread Two is alive: " +
ob2.t.isAlive());
System.out.println("Thread Three is alive: " +
ob3.t.isAlive());
System.out.println("Main thread exiting.");
}
}
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
hey frnds..i have taken an emergency interview date of 21st july and my school is starting from 8th sept...i was continuously checking the date from 10 days but was not able to get a normal date...so can i get a rejection on this, that i have taken an emergency date.??????
Prove that in a self-complementing code the sum of the weights must be 9?
How I can write a java program output the following 1+2+4+7+......N
WHAT IS THE MEANING OF FLASHING VD AND FD INSTALLATION PLENIUM BOXES IN CENTRAL AIR CONDITION
how to connect oracle with java ? Give detail explanation.
Write a program to input 10 elements in an array and seperate even and odd numbers, positive and negative between them ?
Hello sir i finished my BE computer 2009 batch. I'm not gud at programming like 0 knowledge and i'm not interested in it too . Except this programming field is anyother option to afford into a new one ??????? can anyone help me plz
Explain i.d.e. for visual c++?
15. What is your Future Plans for the Company if Permanently Employed?
how u send idocs with out using r.f.c interface
Discuss the various process operations, clearly stating what is involved in each process operation.
what is the differance between a technology and an engineering ?
hi... i just want to know that how could join the AAI with an B.E back ground??? please help me out.
Dear frds In my office we are using chiller . in that chiller inlet and outlet water diff. is 2.5 decgree always. if i intduce the cooling tower can i get good result in chiller Inlet water. reply plz.
explain different access specifiers in class