Skip to content

Commit

Permalink
Put the synchronized around the whole while loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Hocuri committed Jan 10, 2025
1 parent 66fd795 commit 3533916
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ public static void start(Context context) {
// The background fetch was successful, but we need to wait until all events were processed.
// After all events were processed, we will get DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE,
// and stop() will be called.
while (fetchingSynchronously) {
try {
// The `wait()` needs to be enclosed in a while loop because there may be
// "spurious wake-ups", i.e. `wait()` may return even though `notifyAll()` wasn't called.
synchronized (STOP_NOTIFIER) {
synchronized (STOP_NOTIFIER) {
while (fetchingSynchronously) {
try {
// The `wait()` needs to be enclosed in a while loop because there may be
// "spurious wake-ups", i.e. `wait()` may return even though `notifyAll()` wasn't called.
STOP_NOTIFIER.wait();
}
} catch (InterruptedException ex) { }
} catch (InterruptedException ex) {}
}
}
}
}
Expand Down

0 comments on commit 3533916

Please sign in to comment.