lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dawid Weiss <>
Subject Re: Immutable OpenBitSet?
Date Thu, 28 Apr 2011 06:56:56 GMT
There are solutions to solve the initialization problem. The JVM guarantees
> that an object is consistent after the ctor is run, so you can do the
> initialization like this (please note the double {{}}, which is an inline
> ctor, this is also often seen for unmodifiable HashSets):
> final OpenBitSet mybits = new OpenBitSet(size) {{
>        fastSet(1); fastSet(2);...
> }};

To  complete Uwe's hint: note the object is assigned to a final field -- JVM
guarantees publication safety in correlation with final fields or static
initializer (which in turn result from class loading spec). If you Google
for safe publication you'll find a lot of information about this.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message