Jon
Sat Jan 08 06:55:57 CST 2005
Tim Jarvis <TimJarvis@newsgroup.nospam> wrote:
> > There are no particular issues there. The instance itself is still
> > going to be sorted - what kind of issues would you expect, exactly?
> > Could you give an example?
>
> ok, please feel free to completely shoot down my reasoning if it is
> incorrect.
>
> I havn't used reflector to have a look at Array.Sort but it strikes me
> that if you wanted to make it thread safe, you would have to protect /
> lock the instance, and the logical place to do that is in the sort
> method itself, but if you were doing that from a instance method, you
> would have the possibility of a context switch between the call and the
> attempt to protect yourself. Whereas the Static call would not have
> that issue, it can protect the instance then manipulate it.
No, it would have exactly the same issues. You can lock the instance
either from an instance method or a static method - but in both cases
other threads could still modify the contents if they didn't know to
also try to lock it.
--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too