On Fri, Feb 15, 2002 at 11:19:15AM +0100, Sascha Brawer wrote: > Hello, > > the implementations of java.util.Hashtable.size() and > java.util.Hashtable.isEmpty() merely access a single integer member > field. Since accesses to integer variables are required to be atomic, I > think these two methods don't need to be synchronized. Do people agree? > (Yes, it's a micro-optimization). >
I do not agree. If I remeber correctly, this atomicity is only true of "volatile" variables. Otherwise, you have no garantee that the integer value visible to one thread is the same as the one visible to another on a multiprocessor system. Be careful with such "micro-optimizations" which can be based on false assumptions. Let the compilers/VM do these optimizations. Etienne -- Etienne M. Gagnon http://www.info.uqam.ca/~egagnon/ SableVM: http://www.sablevm.org/ SableCC: http://www.sablecc.org/ _______________________________________________ Classpath mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/classpath

