void () { final boolean[] attemps = new boolean[3]; final MyQueue queue = new MyQueue(); final MyUpdate first = new MyUpdate("addedFirstButRunLast") { // default priority is 999 @Override public void run() { super.run(); attemps[0] = true; assertTrue(attemps[1]); assertTrue(attemps[2]); } }; final MyUpdate second = new MyUpdate("addedSecondButRunFirst", Update.HIGH_PRIORITY) { @Override public void run() { super.run(); assertFalse(attemps[0]); attemps[1] = true; assertFalse(attemps[2]); } }; final MyUpdate third = new MyUpdate("addedThirdButRunSecond", 100) { @Override public void run() { super.run(); assertFalse(attemps[0]); assertTrue(attemps[1]); attemps[2] = true; } }; queue.queue(first); queue.queue(second); queue.queue(third); waitForExecution(queue); assertAfterProcessing(first, true, true); assertAfterProcessing(second, true, true); assertAfterProcessing(third, true, true); }