我写了两个线程对同一个socket进行读写,但是读的操作一直不返回,读方法和写方法加了同步关键字,读的不返回导致写的线程一直BLOCKED,不知道是怎么回事儿,线程堆栈入下,请教高手们指点一下:
读的堆栈如下:
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.read(SocketInputStream.java:146)
java.io.DataInputStream.read(DataInputStream.java:149)
java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2282)
java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2295)
java.io.ObjectInputStream$BlockDataInputStream.readUTFBody(ObjectInputStream.java:3035)
java.io.ObjectInputStream$BlockDataInputStream.readUTF(ObjectInputStream.java:2836)
java.io.ObjectInputStream.readString(ObjectInputStream.java:1616)
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1337)
java.io.ObjectInputStream.readObject(ObjectInputStream.java:368)
java.util.HashMap.readObject(HashMap.java:1046)
sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:616)
java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:991)
java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1865)