Skip to content

Commit 34f85d0

Browse files
javier-godoypaodb
authored andcommitted
test: spin until the thread reaches barrier.await
Close #197
1 parent 6db08bb commit 34f85d0

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/test/java/com/flowingcode/vaadin/addons/gridexporter/test/ConcurrentExportTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,14 @@ public MockDownload await() throws InterruptedException {
279279
thread.start();
280280
}
281281
latch.await();
282+
// Spin until the thread reaches barrier.await() (WAITING state).
283+
// latch.countDown() happens before barrier.await(), so there is a window
284+
// where latch==0 but the thread hasn't entered the barrier yet.
285+
// Assumes the barrier has not fired yet; otherwise WAITING could mean
286+
// exchanger.exchange() rather than barrier.await().
287+
while (thread.isAlive() && thread.getState() != Thread.State.WAITING) {
288+
Thread.onSpinWait();
289+
}
282290
return this;
283291
}
284292

0 commit comments

Comments
 (0)