On Thu, 17 Oct 2024 18:43:58 GMT, Phil Race <p...@openjdk.org> wrote:

>> src/java.desktop/share/classes/sun/awt/image/SurfaceManager.java line 102:
>> 
>>> 100:      * and this map is just a weak mapping for the bookkeeping 
>>> purposes.
>>> 101:      */
>>> 102:     private final Map<ProxyCache, WeakReference<SurfaceDataProxy>> 
>>> weakCache = new WeakHashMap<>(2);
>> 
>> why does this one not need to be a synchronized map ?
>
> Ping ! on this .

Because we only use it inside `synchronized` blocks. We need to do this 
explicitly because in one place it is needed for acquiring two monitors in 
particular order, and in second place it covers an iteration loop. Therefore 
there is no need to wrap it into synchronized wrapper.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/20825#discussion_r1805274907

Reply via email to