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 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算