Re: How did it dead lock?
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Wed, 29 Mar 2006 22:13:18 +0100
Helge Jensen <helge.jensen@xxxxxxx> wrote:
If you buy that argument, would you suggest that everything should be
public, too?
Yes, I pretty much do. A side-benefit is much less complicated white-box
testing, since the "hiding" of implementation of state is only a hint,
not enforced.
In that case, I think we so fundamentally disagree that I haven't got
time to fully address your concerns at the moment.
Just a couple of things then:
Locking on explicit lock objects doesn't take unlimited development
No, but it does require the programmer to do something more complicated.
Rules accumulate.
If someone doesn't like rules, they certainly shouldn't attempt
threading. It's inherently complicated, and there are rules that you
really *must* follow in order to make things work reliably.
<snip>
If someone lock(x) on an object, what are they expecting?
lock(this) is preferrable in many cases, most notably those where a
data-structure internally need to lock, but callers also occasionally
need to mutually exclusively invoke multiple methods without intervention.
If you don't know what's locking on each reference, you can't hope to
be confident that you won't get deadlock IMO.
<snip>
A very gifted co-worker and the C2 wiki: http://c2.com/cgi/wiki have
turned me from my old habits of closing everything I didn't see a use
for to a practice where I honestly present everything along with hints
about which risks are taken by using a specific level of knowledge about
the implementation.
When you expose everything, you allow people to rely on everything - in
other words, the current implementation. That's why I don't like the
overuse of inheritance - it fixes the implementation more than a nice
black-box encapsulation. I hate the idea that I'm not free to change my
code later on.
http://www.pobox.com/~skeet/csharp/miscutil/usage/locking.shtml
This link seems to be broken? i get 404.
Whoops - not sure why the s crept in. Try this:
http://www.pobox.com/~skeet/csharp/miscutil/usage/locking.html
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- Re: How did it dead lock?
- From: Helge Jensen
- Re: How did it dead lock?
- References:
- How did it dead lock?
- From: euan_woo
- Re: How did it dead lock?
- From: Brian Gideon
- Re: How did it dead lock?
- From: euan_woo
- Re: How did it dead lock?
- From: Naveen
- Re: How did it dead lock?
- From: euan_woo
- Re: How did it dead lock?
- From: Naveen
- Re: How did it dead lock?
- From: Helge Jensen
- Re: How did it dead lock?
- From: Jon Skeet [C# MVP]
- Re: How did it dead lock?
- From: Helge Jensen
- How did it dead lock?
- Prev by Date: Re: Class casting.
- Next by Date: Re: Deleting a directory
- Previous by thread: Re: How did it dead lock?
- Next by thread: Re: How did it dead lock?
- Index(es):
Relevant Pages
|
Loading