is it because try is in the main?or because it is in the static method?
or something else?
I'm comfused.
public class MyThread extends
Thread {
String myName;
MyThread(String name)
{
myName = name;
}
public void run()
{
for(int i=0; i<100;i++)
{
System.out.println(myName);
}
}
public static void main(String args[])
{
try
{
MyThread mt1 = new MyThread("mt1");
MyThread mt2 = new MyThread("mt2");
mt1.start();
// XXX
//throw new InterruptedException();
if add the upper line ,compile failed and say that can't reach the next line.
mt2.start();
//throw new InterruptedException();
//when i add upper line,it can compile
}
catch(InterruptedException ex)
{
}
}
}