Monitors Are Bad

(Taken from ThreadsConsideredHarmful).

Is it that MonitorsAreBad because of AbstractionInversion or because of RaceConditions?

Mainly RaceConditions and DeadLock. Compare with EventLoopConcurrency?:

The most important point on that page is:

Given the other goals of object oriented programming -- encapsulation, abstraction, composition, and polymorphism -- the interface contract of an abstraction must state everything about its locking behavior needed to use it correctly. This is simply too hard, and very few are able to succeed at it.

In other words, "manual" use of threads and locks is similar to manual memory management, in that it involves maintaining behavioural properties across abstraction boundaries. That is why both are unsuitable for use with ObjectOrientedProgramming.

So what's the alternative?

See MessagePassingConcurrency. (EventLoopConcurrency? is a special case of MessagePassingConcurrency.)


View edit of February 5, 2005 or FindPage with title or text search