|
From: | Eric Blake |
Subject: | Re: Synchronization in java.util.Collections |
Date: | Sat, 16 Nov 2002 08:45:41 -0700 |
User-agent: | Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 |
Dalibor Topic wrote:
Hi, I've looked over Classpath's implementation of synchronized* methods in java.util.Collections, and I don't understand why the synchronized wrapper classes sync on their own specific mutex field instead of syncing on themselves? i.e. why not have all the wrapper methods synchronized and drop the mutex field? That's how kaffe does it.
They sync on the specified mutex so iterators (which are different instances) can sync on the same mutex. It is also essential for correctly implementing things like Map.subMap(), where the sub-map must synchronize on the original map.
-- This signature intentionally left boring. Eric Blake address@hidden BYU student, free software programmer
[Prev in Thread] | Current Thread | [Next in Thread] |