On Sun, 2006-05-07 at 13:48 -0400, P. Oscar Boykin wrote:
> "All public static members of this type are safe for multithreaded
> operations. No instance members are guaranteed to be thread safe."
> 
> Which I believe is boilerplate, but would imply that it might not be
> safe to read in one thread and write in another.

The boilerplate message actually means "don't attempt to use an instance
of Socket from multiple threads simultaneously without using a
synchronization mechanism."  In short, this is bad:

        // Thread 1
        socket.Send (...);

        // Thread 2
        socket.Receive (...);

Instead, you'd need to do this:

        // Thread 1
        lock (socket) {
                socket.Send (...);
        }

        // Thread 2
        lock (socket) {
                socket.Receive (...);
        }

I have no idea if this will actually work with Sockets (you'd have to
test), but that's what the boilerplate message actually refers to --
whether or not you need to provide your own synchronization.

 - Jon


_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to