On Tue, 13 Jun 2006 15:41:45 -0700,
(E-Mail Removed) wrote:
> Thread 1: write "Hello World"
>
> Thread 2: write "Hello World"
>
> Can the end result on the other side of the socket be
>
> Hel Hello lo Wor World ld.
I'm not sure, but I would expect that it wouldn't. I would think that
each thread would finish it's write, but I wouldn't count on it.
>
> Similaly if two threads are reading from the same socket the string
> specified above
>
> The other end of the socket input is
>
> "Networking code is difficult."
>
> Can the result be as follows
>
> Thread 1: Network
> Thread 2: ing co
> Thread 1: de is
> Thread 2: diff
> Thread 1: ic
> Thread 2: ult.
I think that each thread would finish its read before the next thread
started, but, again, I wouldn't count on it.
As someone said in one of the other replies, it doesn't make sense to read
from different threads.
If you want to share data between threads, you're probably better off
using some other method to do so rather than reading from the same socket.
Dan