java - Using a common buffer to read from inputstream and to write to outputstream -
i read network socket's input stream buffer
count = input.read(buffer) then in next line, i'm printing read contents using
str = new string(buffer,0,count); log.e("str",str); then try write pipedoutputstream of pipedinputstream
pipedoutputstream .write(buffer); where,
pipedoutputstream = new pipedoutputstream(pipedinputstream) the problem thread blocking @ pipedoutputstream .write(buffer);
below confirm that, taken thread debugging tool of ddms,

@ java.lang.object.wait(native method) @ java.lang.object.wait(object.java:401) @ java.io.pipedinputstream.receive(pipedinputstream.java:394) @ java.io.pipedoutputstream.write(pipedoutputstream.java:176) @ java.io.outputstream.write(outputstream.java:106) @ java.io.pipedoutputstream.write(pipedoutputstream.java:147) @ java.io.outputstream.write(outputstream.java:82) @ com.example.receiver.run(drcreceiver.java:104) can 1 tell me, why following not working(blocking thread) (grouping statements)
count = input.read(buffer) str = new string(buffer,0,count); log.e("str",str); pipedoutputstream .write(buffer); but following working(not blocking thread) .
count = input.read(buffer) str = new string(buffer,0,count); log.e("str",str); pipedoutputstream .write(str.getbytes()); thanks in advance
have javadoc. here can see: "attempting use both objects single thread not recommended". need thread attempts read data.
Comments
Post a Comment