[concurrency-interest] Stupid Question

Stanimir Simeonoff stanimir at riflexo.com
Tue Feb 12 16:05:32 EST 2013


In some tests Doug Lea found introducing the local var to have increased
performance.
It's a micro optimization. It's not necessary the optimization to be
profitable across different JVMs, though.

Stanimir


On Tue, Feb 12, 2013 at 10:41 PM, <javamann at cox.net> wrote:

> Stupid question time. While going through the code for an ArrayBlockQueue
> I came across numerous instances where the instance 'lock' is copied to a
> variable in a Method. I know there is a reason for this, I just don't know
> what it is.
>
> Thanks
>
> -Pete
>
>     public int remainingCapacity() {
>         final ReentrantLock lock = this.lock;
>         lock.lock();
>         try {
>             return items.length - count;
>         } finally {
>             lock.unlock();
>         }
>     }
>
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20130212/56a03abb/attachment.html>


More information about the Concurrency-interest mailing list