InterruptedException的处理
使用Thread.currentThread().interrupt();
示例
public class ThreadUtil {
private ThreadUtil() {
}
public static void sleep(long millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException e) {
// 处理InterruptedException
// https://www.ibm.com/developerworks/cn/java/j-jtp05236.html
Thread.currentThread().interrupt();
}
}
public static void sleep(int i, TimeUnit timeUnit) {
sleep(timeUnit.toMillis(i));
}
}