Over a million developers have joined DZone.

Is Your Java Eclipse Plugin Thread Safe?

A look at race conditions, what they are, and how they work inside Eclipse Luna.

· Java Zone

What every Java engineer should know about microservices: Reactive Microservices Architecture.  Brought to you in partnership with Lightbend.

...Or Does It Contain Race Conditions?

A race condition happens when the outcome of the program depends on the sequence or timing of other uncontrollable events. It becomes a bug when events do not happen in the order the programmer intended. https://en.wikipedia.org/wiki/Race_condition

We searched inside Eclipse for race conditions to see the most common types of race conditions inside Eclipse and its plugins.

The following types of race conditions were found by vmlens inside Eclipse Luna during startup and debugging of a jJava project:


No Synchronization At All

The most common cause for race conditions was accessing the same field from different threads without any synchronization at all.



Concurrently Accessed Fields


Fields Traced








Volatile Fields


During this run 2065 different fields were accessed by more than one thread, 4 of them without synchronization.

2836 volatile fields were used. For 3 more fields it would have been necessary to declare them as volatile. This leads to the second type of race conditions found, visibility problems.


A field is accessed by many threads, but not declared as volatile.

The JVM does not directly write field updates into the main memory but first in registers or a cache of your CPU. As long as your program is running on one core of your PC, this is not a problem. But if the threads runs on different cores, they probably will not see the updates to the fields.

This problem appears most often with boolean flags. Like the terminated field of org.eclipse.equinox.internal.util.impl.tpt.timer.TimerImpl in the run method:

public void run() {
        TimerQueueNode n = null;
        while (!terminated) {
            synchronized (sync) {
                if (n == null && queue.isEmpty()) {
                    try {
                    } catch (Exception e) {
                    // todo check if isEmpty is necessary
                    if (queue.isEmpty() || terminated) {


For 2065 concurrently accessed fields, vmlens found 7 race conditions. All other were correctly synchronized by 7162 monitors or declared as volatile.

Microservices for Java, explained. Revitalize your legacy systems (and your career) with Reactive Microservices Architecture, a free O'Reilly book. Brought to you in partnership with Lightbend.

java,eclipse 4,race conditions

Published at DZone with permission of Thomas Krieger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}