Fix data race in MultiProgressMonitor
This is work related to [1] and [2]. Synchronizing on different objects (Task vs Monitor) doesn't have much sense as it results (sooner or later) in deadlocks. This is an attempt to synchronize on monitor object only (note that Task.getCount() is called from outside the monitor when processing is basically done). [1] https://gerrit-review.googlesource.com/#/c/87442/ [2] https://gerrit-review.googlesource.com/#/c/91132/ Change-Id: I99b5da03d5d9ecc9a2fa0d6ca022d6e026d45aba
This commit is contained in:
@@ -81,7 +81,7 @@ public class MultiProgressMonitor {
|
||||
@Override
|
||||
public void update(final int completed) {
|
||||
boolean w = false;
|
||||
synchronized (this) {
|
||||
synchronized (MultiProgressMonitor.this) {
|
||||
count += completed;
|
||||
if (total != UNKNOWN) {
|
||||
int percent = count * 100 / total;
|
||||
@@ -124,8 +124,10 @@ public class MultiProgressMonitor {
|
||||
return false;
|
||||
}
|
||||
|
||||
public synchronized int getCount() {
|
||||
return count;
|
||||
public int getCount() {
|
||||
synchronized(MultiProgressMonitor.this) {
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user