Why jucCopyOnWriteArrayList creates a local lock variable inside methods

I recently checked the jucCopyOnWriteArrayList implementation in OpenJDK sources and found that the lock variable defined inside the class is updated with the following statement

final ReentrantLock lock = this.lock;

inside all methods requiring this variable. Any specific reason for such a reevaluation of a variable (which may conceal a global variable). You cannot directly use the "lock" field of an object.

+3
source share
1 answer

. , , -. HotSpot , .

+7

Source: https://habr.com/ru/post/1768105/


All Articles