Subj : Re: Java vs. C++ To : comp.programming.threads From : Joe Seigh Date : Sat May 28 2005 07:53 am On Sat, 28 May 2005 08:04:35 GMT, dayton wrote: > > -- The Java synchronization model is rather broken. If one object with > synchronized methods contains another object with synchronized methods, > you become subject to deadlock because you haven't acquired all the > required locks at once -- and you have no control of the level of the locks. It's not broken. It's more of an issue with mindlessly making all class methods synchronized in the mistaken belief that this is all you need to do it make things threadsafe. In an OO environment where method calls tend to behave like callbacks, this leads to a lot of deadlock. Granted Java's decision to incorporate monitors as part of the base Object class does nothing to disabuse this notion, but it's mainly due to this not being made clear when Java is taught. You have frequently recurring proposals to do the same thing in C++ with various wrapper mechanisms to make all accesses of an object "threadsafe" and they all have the same problem with deadlock. -- Joe Seigh When you get lemons, you make lemonade. When you get hardware, you make software. .