Java Lock variable assignment before use. Why?

前端 未结 5 1669
迷失自我
迷失自我 2020-12-06 07:11

In a lot of of the Java source, (for example LinkedBlockingDeque) I see things like this;

final ReentrantLock lock = new ReentrantLock();

publi         


        
5条回答
  •  臣服心动
    2020-12-06 07:47

    Whilst it shouldn't make any difference, it has been stated on mailing lists that there have been slight measured performance difference on actual JREs.

    General advice would still be not to bother with the local. It's only there because performance is really, really crucial in specific code used by a lot of people.

提交回复
热议问题