Subj : Re: Improving read-write lock To : comp.programming.threads From : David Holmes Date : Fri Feb 25 2005 05:47 pm "Marcin 'Qrczak' Kowalczyk" wrote in message news:878y5dsoov.fsf@qrnik.zagroda... > This situation should be detected by the fact that an exception is > thrown where it shouldn't be. But by then it may be too late. If the buggy application has already been deployed then the fact the exception occurred may not have prevented the object from being accessed while in an invalid state and so corrupt data being produced. Would you rather the bug caused a hang that meant the database didn't get updated, or that the bug generated an exception but allowed junk to be written to the database. ??? But it is not a simple story. Once things are broken the response to be being broken depends very much on the severity of the problem brokenness might cause. If the exception propogates and locks are not released then recovery may be impossible without locks that support ownership-stealing. I like to think that releasing the lock at least allows for the possibility of recovery - but really how do you recover from an unexpected exception. In most cases, most programs just give up and die, or give up and hang. The current scheme, in Java at least, does make it allowable to write things like: public synchronized void doIt(int x) { if (x < 0) throw new IllegalArgumentException(); .. } Though I know many here would argue the above is terrible style anyway. But that's not a debate I'm going to get dragged into. David Holmes .