honor10000 2014-05-04 09:35
浏览 1968

线程死掉了,还是阻塞了,为什么

我在servlet里创建了一个timer,并在timer中定义了一个timertask,(2分钟执行一次timertask中的run方法)并且没有写任何中断timer的语句

出现了下面的问题(这个问题出现的几率相当小)

后台的日志:

打印了arr_xml_rq00 doSend()66666666 但是没有打印arr_xml_rq00 doSend()77777777,没有异常出现(下面的程序片段在一个try catch 语句块儿中,可以肯定这块程序没有抛出异常)

对应的程序片段:

HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("User-agent","Mozilla/4.0");
connection.setDoOutput(true);
//Read from the connection. Default is true.
connection.setDoInput(true);
//Set the post method.默认是get
connection.setRequestMethod("POST");
//Post 请求不能使用缓存
connection.setUseCaches(false);
connection.setInstanceFollowRedirects(false);
log.info("arr_xml_rq00 doSend()4444444");
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
out.writeBytes(sendXmlLast.toString());
log.info("arr_xml_rq00 doSend()55555555");
out.flush();
out.close();

log.info("arr_xml_rq00 doSend()66666666");

BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8"));

    String readLine = "";
    sb = new StringBuffer();

    while ((readLine = in.readLine()) != null) {
      sb.append(readLine);
    }

    in.close();
    log.info("arr_xml_rq00 doSend()77777777");

之后timertask再也没有执行过,(因为我还在timertask的run中log.info了别的信息,那些信息没有打印证明了这一点)

请问是线程死掉了,还是永久阻塞了.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 蓝牙耳机怎么查看日志
    • ¥15 Fluent齿轮搅油
    • ¥15 八爪鱼爬数据为什么自己停了
    • ¥15 交替优化波束形成和ris反射角使保密速率最大化
    • ¥15 树莓派与pix飞控通信
    • ¥15 自动转发微信群信息到另外一个微信群
    • ¥15 outlook无法配置成功
    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏