<AWT Dev> Question regarding locking in EventQueue

Artem Ananiev artem.ananiev at oracle.com
Tue Nov 16 03:01:05 PST 2010

Hi, Roman,

the only reason why ReentrantLock was used is that java.util.concurrent 
locks are considered slightly more efficient than regular Java monitors. 
I didn't perform any measurements for this particular change in 
EventQueue, though, it's just based on my past experience.



On 11/16/2010 1:56 PM, Roman Kennke wrote:
> I was just looking at how locking has changed in OpenJDK7 (because I
> have problems with deadlocks in JDK6), and see that it now uses one
> global (i.e. appctx local) lock to protect EQ internal structures, as
> opposed to locking on single EQ objects as was done before. So far so
> good, this will most likely solve my deadlock problems.
> I was just wondering why is ReentrantLock used instead of simply using
> the Java language synchronized construct? The way the locks are used, it
> seems to be clearer, more straightforward and less error-prone to use
> the language constructs rather than concurrent API. Is there a specific
> reason for that?
> Kind regards, Roman

More information about the awt-dev mailing list