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 thinkphp6配合social login单点登录问题
    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch