Java Swing UI Thread Event isEDT()

Here you can find the source of isEDT()

Description

Returns TRUE if current thread is EDT.

License

Open Source License

Return

TRUE if current thread is EDT.

Declaration

public static boolean isEDT() 

Method Source Code


//package com.java2s;
// the terms of the GNU General Public License as published by the Free Software Foundation;

import javax.swing.*;

public class Main {
    private static final ThreadLocal<Boolean> EDT_FLAG = new ThreadLocal<Boolean>();

    /**/*from   w  w  w. j a v  a2  s.  c  o  m*/
     * Returns TRUE if current thread is EDT.
     *
     * @return TRUE if current thread is EDT.
     */
    public static boolean isEDT() {
        Boolean bool;

        synchronized (EDT_FLAG) {
            bool = EDT_FLAG.get();
            if (bool == null) {
                bool = SwingUtilities.isEventDispatchThread();
                EDT_FLAG.set(bool);
            }
        }

        return bool;
    }
}

Related

  1. invokeOnEventThread(Runnable r)
  2. invokeOnEventThread(Runnable r)
  3. invokeOnEventThread(Runnable runnable)
  4. isEDT()
  5. isEDT()
  6. isEventDispatchThread()
  7. isEventDispatchThread()
  8. isLinefeedTag(HTML.Tag tag)
  9. onShowingChanged(final JComponent component, final Runnable callback)