Here you can find the source of doLater(final long milliseconds, final Runnable doThis)
public static Thread doLater(final long milliseconds, final Runnable doThis)
//package com.java2s; /*//www . ja va2 s .c o m Copyright 2006 by Sean Luke and George Mason University Licensed under the Academic Free License version 3.0 See the file "LICENSE" for more information */ import javax.swing.*; public class Main { /** Schedule something to occur at some specified point in the future in the Swing Event thread. */ public static Thread doLater(final long milliseconds, final Runnable doThis) { Thread thread = new Thread(new Runnable() { public void run() { try { Thread.sleep(milliseconds); SwingUtilities.invokeAndWait(doThis); } catch (InterruptedException e) { /* shouldn't happen -- we could do an invokeAndWait in case tho */ } catch (java.lang.reflect.InvocationTargetException e) { /* shouldn't happen */ } } }); thread.start(); return thread; } }