Martin van Beilen wrote: > Andy Ross wrote: > > For those with Java experience, consider the Vector class. It's > > threadsafe, right? > > No, it's not. Imagine what happens when one thread is reading it > while another thread is writing to it. :-) > > > Right. Now enumerate over it in one thread while > > modifying it in another. Is *that* threadsafe? :) > > Now what did I just say? Pay attention please. ;-)
You missed my point. First, the Vector class *is* threadsafe; check all the methods, they're synchronized. There is no way, in Java, to corrupt the state of a Vector object by modifying it in multiple threads. Each thread is guaranteed to see a consistent object; there is no way to add two elements at the same index, for example, or to remove an item more than once. The library designers got this part right. Your suggestion about how to add threadsafety to the property system would achieve the same level of functionality. My point was that this buys you *nothing*. You can still write all the race conditions you want by assuming that the object won't be modified from another thread. See my post about the nuclear bomb safety lock; even a perfectly threadsafe property system is susceptible to race conditions. The point, again: *all* multithreaded code is susceptible to race conditions and deadlocks. There is *no* way around this. The only way to avoid them is to be very, very careful with your design. You cannot rely on libraries to save you. You cannot rely on simple techniques to save you. You have only your mind, your experience, and the minds and experience of the yahoo threading cowboys working on the rest of the project to rely on. Now, are you getting the point? :) Andy -- Andrew J. Ross NextBus Information Systems Senior Software Engineer Emeryville, CA [EMAIL PROTECTED] http://www.nextbus.com "Men go crazy in conflagrations. They only get better one by one." - Sting (misquoted) _______________________________________________ Flightgear-devel mailing list [EMAIL PROTECTED] http://mail.flightgear.org/mailman/listinfo/flightgear-devel