Monitors Are Bad

(Taken from ThreadsConsideredHarmful).

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


Mainly RaceConditions and DeadLock. Compare with EventLoopConcurrency?: http://www.erights.org/elib/concurrency/event-loop.html

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.)


CategoryConcurrency

EditText of this page (last edited February 5, 2005) or FindPage with title or text search