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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)