This is probably a very simple question, but it's hard for me to find the answer.
Is it possible to write one stream to the Socket output stream while another stream is reading from the Socket input stream?
Edit: This is a client application that accesses an external server. I am not trying to get these topics to talk to each other. Sorry for the ambiguity.
Assuming that you mean that threads use the same socket to communicate with an external entity, and not with each other, this is pretty common because you often don't want to block while waiting to read from the socket.
Thread1:
block on read on recieve message - do something
Thread 2:
do things on something happening - write to socket
, , .
: concurrency, , , , .
, ", , ", " , , , , ". , โโ , , . : . , . , .
. , (POP, IMAP, HTTP ..), , , , ., - , , . , , - - RTMP, . , , -, .
, , , . , , . , , , . -. , / , / - . -, , .
, , / .
, ? , . ( , ), .
, , , , .
- .
: :
: , , , , . , . -, , , .
, . AFAIK , , .
, . , , .
. http://vanillajava.blogspot.com/2011/11/java-puzzle-single-threaded-client.html
, , BlockingQueue (s) Exchanger ByteBuffers .;)
, ""? - BlockingQueue
, , . . , ,