Subj : Re: [Rhino] Java trick To : netscape.public.mozilla.jseng From : igor@icesoft.no (Igor Bukanov) Date : Thu Jan 09 2003 02:44 am The comments refer to the classTable field itself, not a Hashtable instance it refers. classTable will be set to a new value during cache reset and to refer to the same hashtable during method execution a local reference is used. It is OK not to use synchronization here as if classTable is changed by another thread, it would only mean that cached class information has to be created one more time. Regards, Igor "Todd Trimmer" wrote in message news:... > I see comments in Rhino source, like in org.mozilla.javascript.JavaMembers: > > Hashtable ct = classTable; // use local reference to avoid synchronize > > Is this true? If I have a local reference to a member field, it becomes > automatically thread-safe? I thought this safety only happens if I created > the object and the reference locally? How does this trick work? If I call > the same method twice, once in each method, even though in each I have a > localized reference, I'm still pointing to the same memory chunk, aren't I? > Does this trick only apply to classes that already have synchronized methods > like Hashtable does? > > > Todd Trimmer .