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条回答

    报告相同问题?

    悬赏问题

    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
    • ¥30 python代码,帮调试
    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊