display.readAndDispatch();
if (!display.readAndDispatch ()) display.sleep();
public void test_timerExecILjava_lang_Runnable() {	final Display display = new Display();	try {		final boolean[] timerExecRan = new boolean[] {false};		final boolean[] threadRan = new boolean[] {false};				try {			display.timerExec(0, null);			fail("No exception thrown for timerExec with null runnable");		} catch (IllegalArgumentException e) {			assertEquals("Incorrect exception thrown for timerExec with null runnable", SWT.ERROR_NULL_ARGUMENT, e);		}				display.timerExec(-100, new Runnable() {			public void run() {				timerExecRan[0] = true;			}		});						final int delay = 3000;		final long startTime = System.currentTimeMillis();		display.timerExec(delay, new Runnable() {			public void run() {				long endTime = System.currentTimeMillis();				// debug intermittent test failure				if (endTime < (startTime + delay)) {					System.out.println("Display.timerExec ran early " + ((startTime + delay) - endTime));				}				//assertTrue("Timer ran early! ms early: ", endTime >= (startTime + delay));				threadRan[0] = true;			}		});		while (!threadRan[0]) {			// The read and dispatch loop must be running in order			// for the runnable in the timer exec to be executed.			display.readAndDispatch();		}				// Verify the timerExec with less than zero milliseconds didn't execute.		assertFalse("< 0 ms timer did execute", timerExecRan[0]);	} finally {		display.dispose();	}}