Skip to content

Commit f7b78a8

Browse files
committed
TaskEventTest: reduce wait time overhead
We can terminate as soon as all tasks finish, before 5s elapses.
1 parent dacd7b1 commit f7b78a8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/test/java/org/scijava/task/TaskEventTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ public void testManyTasks() throws InterruptedException {
7272
for (int i=0;i<nTasks;i++) {
7373
createTask(taskService, "Task_"+i, 100, 10, 100);
7474
}
75-
Thread.sleep(5000);
75+
// Wait up to a few seconds for all tasks to complete.
76+
long start = System.currentTimeMillis();
77+
long maxWaitTime = 5000;
78+
while (System.currentTimeMillis() - start < maxWaitTime) {
79+
if (eventListener.tasks.isEmpty()) break; // done!
80+
Thread.sleep(10);
81+
}
7682
assertEquals(0, eventListener.getLeftOvers().size());
7783
}
7884

0 commit comments

Comments
 (0)