vaishnavi
03-11-2009, 06:15 AM
Hi All,
I am bit confused about the way sleep() and InterruptedException works. While using sleep(), is it mandatory to use InterruptedException? As far as I know, we should use the exception, but the following code works fine even without the exception which confuses me.
public class exceptiondemo
{
public static void main(String args[])throws Exception
{
Thread.sleep(3000);
System.out.println("sleep");
}
}
I am bit confused about the way sleep() and InterruptedException works. While using sleep(), is it mandatory to use InterruptedException? As far as I know, we should use the exception, but the following code works fine even without the exception which confuses me.
public class exceptiondemo
{
public static void main(String args[])throws Exception
{
Thread.sleep(3000);
System.out.println("sleep");
}
}