When does Java’s Thread.sleep throw InterruptedException?

You should generally NOT ignore the exception. Take a look at the following paper: Don’t swallow interrupts Sometimes throwing InterruptedException is not an option, such as when a task defined by Runnable calls an interruptible method. In this case, you can’t rethrow InterruptedException, but you also do not want to do nothing. When a blocking … Read more

How can I kill a thread? without using stop();

The alternative to calling stop is to use interrupt to signal to the thread that you want it to finish what it’s doing. (This assumes the thread you want to stop is well-behaved, if it ignores InterruptedExceptions by eating them immediately after they are thrown and doesn’t check the interrupted status then you are back … Read more