[Mono-list] yield

Jeroen Frijters jeroen at sumatra.nl
Fri Sep 23 03:39:57 EDT 2005


Bernhard Herzog wrote:
> > > Basically yield and lock dont mix.
> > That's definitely true. Even though it "works", it's still 
> a bad idea.
> 
> Ok, so why is it a bad idea then (if it does what I want, at least in 
> MS.Net, doesn't it?). Actually I already removed my yield 
> code to avoid problems, but using yield would have been nice.

You are essentially exposing a locking API that the client (caller)
doesn't know about and this makes it very deadlock prone. Also, since
you don't control the lifetime of the lock, you have no idea how long
the lock will be held, this is generally also not a very good idea.

Regards,
Jeroen


More information about the Mono-list mailing list