Doğacan Güney wrote:
On Mon, Oct 13, 2008 at 12:43 AM, Jim Kellerman (POWERSET)
<[EMAIL PROTECTED]> wrote:
No, the change to RegionHistorian was only to make the instantiation
of the singleton thread safe, which it was not before.
IIRC what I read about java memory model, you do not need synchronized
there if you make a few changes:
/** Singleton reference */
private static RegionHistorian historian = new RegionHistorian();
I think if you do this, Java guarantees that historian won't be
initialized until it is accessed
(because static members are only initialized when a class is loaded)
and it will be thread-safe.
So you can get rid of "synchronized" in getInstance.
Agreed. The above is more the idiom but for some reason, the
RegionHistorian needs to be lazily instantiated (I looked into this
before but don't remember why -- smile). I tried changing it yesterday
and ran unit tests. They failed. It seems the lazy-instantiation is
still necessary.
St.Ack