commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Ring <...@jdns.org>
Subject Re: Pointers
Date Fri, 28 Jan 2011 22:21:27 GMT
Hey,

On Fri, Jan 28, 2011 at 2:01 PM, Stephen Williams <scienteer@gmail.com> wrote:
> All objects are passed as references in Java.
> All fundamental scalar types have Object wrapped versions.
> An argument that is meant to be modified just needs to be an object
> reference.
>
> So, you can simply go from:
> void funkyReader(int arg) { arg++; }
> to:
> void funkyChanger(Integer arg) { arg++; }
>
> If it needs to be threadsafe, simply synchronize on the object everywhere it
> is used.

It's a bad idea to synchronize on the wrapper objects of primitive
types: http://www.theothertomelliott.com/node/40

This includes Integers.

Regards,
James

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message