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...


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

Differences between Java and C++? which is faster?

0 Answers   Impetus,


four jobs j1,j2,j3 and j4 are waiting to be run. Their expected runtimes are 9,6,3 and 5 respectively. In order to minimize average response time, the jobs should be run in the order: a) j1j2j3j4 b)j4j3j2j1 c)j3j4j1j2 d)j3j4j2j1

2 Answers   TCS, UGC NET,


can anyone help me with an article or a few pointers on what are the industry expectations from Fresh engineers in today's market scenario

0 Answers  


can any give an exact example about, resolving the sql errorcode -305

0 Answers   TCS,


difference between multi relational OLAP & multidimensional OLAP

1 Answers  


how to conrtruct gear make him rotate on its axis

0 Answers  


difference between tcp ip and open system interconnection

0 Answers  


why we select you?

0 Answers  


the interviewer ask me If i accept to in lower position than the one i was tested for

2 Answers  


What is your happiest moment in your life

0 Answers  


HOW CAN YOU RELATE THE FUNCTION WITH STRUCTURE EXPLAIN WITH APPROPRIATE EXAMPLES

0 Answers  


what is defect tracking in sotware testing

0 Answers  


Categories
  • Civil Engineering Interview Questions Civil Engineering (5086)
  • Mechanical Engineering Interview Questions Mechanical Engineering (4456)
  • Electrical Engineering Interview Questions Electrical Engineering (16639)
  • 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)