[concurrency-interest] Primitives wrappers and visibility problems

Peter Veentjer alarmnummer at gmail.com
Wed Aug 23 05:55:29 EDT 2006


I have checked the source of java 1.3.1.18 and it doesn't contain a
final. The final must have been introduced in 1.4 or 1.5.

And the final doesn't add any value in vm that 'support' the older JMM anyway ;)

But it is good to know it is final in the newest version of Java.

On 8/23/06, Kasper Nielsen <kav at it.edu> wrote:
> Peter Veentjer wrote:
> > I have another question about visibility problems. Someone suggested
> > to me that the primitve wrappers (like Integer) don't use a final
> > field for the primitive they contain. This would make them not
> > threadsafe. Is this correct?
> > _______________________________________________
> > Concurrency-interest mailing list
> > Concurrency-interest at altair.cs.oswego.edu
> > http://altair.cs.oswego.edu/mailman/listinfo/concurrency-interest
> >
>
> You could take a peek in the source:
>
>     /**
>      * The value of the <code>Integer</code>.
>      *
>      * @serial
>      */
>     private final int value;
>
>     /**
>      * Constructs a newly allocated <code>Integer</code> object that
>      * represents the specified <code>int</code> value.
>      *
>      * @param   value   the value to be represented by the
>      *                 <code>Integer</code> object.
>      */
>     public Integer(int value) {
>        this.value = value;
>     }
>
> - Kasper
>


More information about the Concurrency-interest mailing list