HttpURLConnection被锁定 [英] HttpURLConnection getting locked
问题描述
我在tomcat下运行了一个线程,它创建了一个HttpUrlConnection并通过BufferedInputStream读取它。
I have a thread running under tomcat which creates a HttpUrlConnection and reads it through BufferedInputStream.
获取某些url的数据后,它会停止。我得到了进程的jstack,它说HttpUrlConnection被锁定,BufferedInputStream也被锁定。
After fetching data for some urls, it stalls. I got the jstack of the process which says HttpUrlConnection is locked and BufferedInputStream is also locked.
"http-8080-1" daemon prio=10 tid=0x08683400 nid=0x79c9 runnable [0x8f618000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:129)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
- locked <0x956ef8c0> (a java.io.BufferedInputStream)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:687)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:632)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1072)
- locked <0x956ef910> (a sun.net.www.protocol.http.HttpURLConnection)
有人可以在这里提供帮助。
谢谢
Could somebody help here. Thanks
推荐答案
你可能在另一端有问题。 InputStream上的read()是一个阻塞操作 - 来自javadoc( http:// java .sun.com / javase / 6 / docs / api / ):此方法将阻塞,直到输入数据可用,检测到流的末尾或抛出异常。
You probably have a problem on the other end. read() on an InputStream is a blocking operation - from the javadoc (http://java.sun.com/javase/6/docs/api/): "This method blocks until input data is available, the end of the stream is detected, or an exception is thrown."
另一端的服务器是否响应?你知道它是否发送了什么?
Is the server on the other end responding? Do you know if it's sent anything?
编辑:为了使它更清晰,线程处于RUNNABLE状态,所以你没有陷入僵局 - 这听起来像是你的我认为确实如此,但没有任何证据证明存在任何僵局。
edit: To make it clearer, the thread is in RUNNABLE state, so you're not deadlocked - it sounds like that's what you're thinking that it is, but there's no evidence here of any deadlock.
这篇关于HttpURLConnection被锁定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!