void () { final MyQueue queue = new MyQueue(); StringBuilder expected = new StringBuilder(); final StringBuilder actual = new StringBuilder(); for (int i = 0; i < 20; i++) { expected.append(i); final int finalI = i; queue.queue(new Update(new Object()) { @Override public void run() { actual.append(finalI); } }); } queue.showNotify(); waitForExecution(queue); assertEquals(expected.toString(), actual.toString()); }