wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Threads" Watch "Threads" New topic
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: 2578

Statement on line //1 is an infinite loop which will not terminate, hence staement //3 is unreachable.
HTH,
- Manish
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Threads