pls explain this prog logic



pls explain this prog logic..

Answer / 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

More Engineering AllOther Interview Questions

What is the pressure in co2 cartridge in a DCP 5 kg extinguisher.

0 Answers   L&T, Samsung,


i am shortlisted in corporation bank for the post of computer officer the next phase is group discussion. i want to know how to prepare and what about the topics for preparing thanking you if you have any suggestion please give me prabhatmishra21@rediffmail.com

0 Answers   Corporation Bank, State Bank Of India SBI,


what are the advantages as disadvantages of the V-model?

0 Answers  


What's the range of C/A?

2 Answers   Ericsson,


what is your weaknesses

0 Answers   Genco, TCS,






how can i install windows-xp operating system in single time to 50 computersconnected in a LAN.

0 Answers   Bank Of America,


can 25mm thik and 8.5x8.5 size cast iron plate can bear a weight of 250 tons if it can what would be the compostion

0 Answers  


if a customer's blackberry stopped syncing their calendar wirelessly what would you do?if a customber deleted mail from his blackberry but it did delete from his mailbox how would ypu resolve this

0 Answers  


2. A product selected for testing is equally likely to have been produced by one the 6 machines/processes. (i) Determine sample space ā€˜Sā€™ (ii) What is the probability that the product is from machine 1? (iii) What is the probability that the product is from machine 2 or machine 4? (iv) What is the probability that the product is from both machine 5 and machine 3? (v) What is the probability that the product is not from machine 6? (vi) What is the probability that the product is not from either machine 6 or machine 1?

0 Answers  


Write a Java program that takes an integer from the user and extracts and displays each digit of the integer in English. So, if the user types in 932, the program will display nine three two. [Use SimpleInput class]

0 Answers  


What questions and tests would i be given to becme a service enginner 2 for a train company repairing trains

1 Answers  


Can you delink a payer from a bill to sold to ship to and then create a new payer on the existing bill to sold to ship to, this is where a pub or club changes licencees and we want to icolate the debt from the old owner but keep the sales history on the ship to/sold to

0 Answers   BOC,


Categories
  • Civil Engineering Interview Questions Civil Engineering (5085)
  • Mechanical Engineering Interview Questions Mechanical Engineering (4451)
  • Electrical Engineering Interview Questions Electrical Engineering (16632)
  • Electronics Communications Interview Questions Electronics Communications (3918)
  • Chemical Engineering Interview Questions Chemical Engineering (1095)
  • Aeronautical Engineering Interview Questions Aeronautical Engineering (239)
  • Bio Engineering Interview Questions Bio Engineering (96)
  • Metallurgy Interview Questions Metallurgy (361)
  • Industrial Engineering Interview Questions Industrial Engineering (259)
  • Instrumentation Interview Questions Instrumentation (3014)
  • Automobile Engineering Interview Questions Automobile Engineering (332)
  • Mechatronics Engineering Interview Questions Mechatronics Engineering (97)
  • Marine Engineering Interview Questions Marine Engineering (124)
  • Power Plant Engineering Interview Questions Power Plant Engineering (172)
  • Textile Engineering Interview Questions Textile Engineering (575)
  • Production Engineering Interview Questions Production Engineering (25)
  • Satellite Systems Engineering Interview Questions Satellite Systems Engineering (106)
  • Engineering AllOther Interview Questions Engineering AllOther (1379)