[gclist] Garbage collection and XML
Boehm, Hans
hans_boehm@hp.com
Wed, 7 Mar 2001 09:16:33 -0800
> -----Original Message-----
> From: Bill Foote [mailto:Bill.Foote@eng.sun.com]
> "Richard A. O'Keefe" wrote:
> > I don't know about Javascript, but in Java it is perfectly
> possible to
> > have two String objects with the same (immutable!) state
> which must act
> > the same for all future time, but have distinct identities. A Java
> > program which tried to keep track of which nodes strings
> came from by
> > using String identities as keys could be confused if
> strings were shared.
>
> Ah, good point. It is theoretically possible to use string
> identities to
> discriminate String objects. You'd have to be mad to try,
> and it's not
> easy, but you can: ...
You could presumably also synchronize on the strings, effectively turning
them into locks. In that case sharing might result in unexpected lock
contention or deadlock. The fact that every object can be used for
synchronization means that in some sense nothing is immutable.
Hans