2014年1月24日
摘要: 有没有发生过这样的情况,你写的工作线程莫名其妙的挂了,如果不是被你刚好看到,拿只能抓瞎了,不知道啥原因了,因为异常的时候只会把stack trace打在控制台上,不会记在你想记得错误日志里,头皮都抓破了也没能找到确切的地方,最后只能在能加try catch 的地方都给加上。 Java的异常可以分为这两类,Checked Exceptions和Unchecked Exceptions。 checked exception例子FileNotFoundException,IOException,... unchecked exception例子NumberFormatException... 阅读全文
posted @ 2014-01-24 16:06 好记性不如烂博客 阅读(5285) 评论(0) 推荐(0) 编辑
摘要: 现有线程对象threadA,调用threadA.interrupt(),则threadA中interrupted状态会被置成false,很多线程中都是通过isInterrupted()方法来检测线程是否中断,但在使用该过程中需要注意,run()方法中是否有其他代码捕获了InterruptedException异常,如果是,则会出现线程无法中断的可能性,主要代码如下:public class DemoTest() { public static void main(String[] args) { new DemoTest(); } public DemoTest... 阅读全文
posted @ 2014-01-24 12:58 好记性不如烂博客 阅读(577) 评论(0) 推荐(0) 编辑