<AWT Dev> Question regarding locking in EventQueue

Roman Kennke roman at kennke.org
Tue Nov 16 02:56:42 PST 2010

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