edu.umd.cs.findbugs.AWTEventQueueExecutor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spotbugs Show documentation
Show all versions of spotbugs Show documentation
SpotBugs: Because it's easy!
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);
}
}
}