All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.umd.cs.findbugs.AWTEventQueueExecutor Maven / Gradle / Ivy

The newest version!
package edu.umd.cs.findbugs;

import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.AbstractExecutorService;
import java.util.concurrent.TimeUnit;

import javax.swing.SwingUtilities;

public class AWTEventQueueExecutor extends AbstractExecutorService {
    @Override
    public void shutdown() {
        // nothing to do here
    }

    @Override
    public List shutdownNow() {
        return Collections.emptyList();
    }

    @Override
    public boolean isShutdown() {
        return true;
    }

    @Override
    public boolean isTerminated() {
        return true;
    }

    @Override
    public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
        return true;
    }

    @Override
    public void execute(Runnable command) {
        if (SwingUtilities.isEventDispatchThread()) {
            command.run();
            return;
        }
        try {
            SwingUtilities.invokeAndWait(command);
        } catch (InterruptedException e) {
            throw new IllegalStateException(e);
        } catch (InvocationTargetException e) {
            throw new IllegalStateException(e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy