| Author |
Threads
|
Tanuja Vaid
Ranch Hand
Joined: Mar 07, 2002
Posts: 51
|
|
lass A extends Thread { public void run() { System.out.println("Starting loop"); while(true){}; //1 System.out.println("Ending loop");//3 } } public class TestClass { public static void main(String args[]) throws Exception { A a = new A(); a.start(); Thread.sleep(1000); a.interrupt(); } } The above code when compiled gives an error saying line 3 is an unreachable statement. Can anybody explain why? Thanks in Advance. Tanuja
|
 |
Tanuja Vaid
Ranch Hand
Joined: Mar 07, 2002
Posts: 51
|
|
I GOT IT! SAVED U GUYS A TROUBLE
|
 |
Arun Pai
Ranch Hand
Joined: Mar 11, 2002
Posts: 143
|
|
|
Tanuja, What's the answer?
|
 |
Manish Hatwalne
Ranch Hand
Joined: Sep 22, 2001
Posts: 2573
|
|
Statement on line //1 is an infinite loop which will not terminate, hence staement //3 is unreachable. HTH, - Manish
|
 |
 |
|
|
subject: Threads
|
|
|