Wait and notify on the correct lock.
Dieser Commit ist enthalten in:
Ursprung
db8db1fba1
Commit
af2d692c59
@ -152,7 +152,7 @@ public class AsyncListenerHandler {
|
||||
|
||||
synchronized (stopLock) {
|
||||
stoppedTasks.remove(id);
|
||||
notifyAll();
|
||||
stopLock.notifyAll();
|
||||
running.set(false);
|
||||
}
|
||||
|
||||
@ -269,11 +269,13 @@ public class AsyncListenerHandler {
|
||||
* @throws InterruptedException - If the current thread was interrupted.
|
||||
*/
|
||||
private boolean waitForStops() throws InterruptedException {
|
||||
synchronized (stopLock) {
|
||||
while (stoppedTasks.size() > 0 && !cancelled) {
|
||||
wait();
|
||||
stopLock.wait();
|
||||
}
|
||||
return cancelled;
|
||||
}
|
||||
}
|
||||
|
||||
// DO NOT call this method from the main thread
|
||||
private void listenerLoop(int workerID) {
|
||||
@ -286,10 +288,8 @@ public class AsyncListenerHandler {
|
||||
|
||||
try {
|
||||
// Wait if certain threads are stopping
|
||||
synchronized (stopLock) {
|
||||
if (waitForStops())
|
||||
return;
|
||||
}
|
||||
|
||||
// Proceed
|
||||
started.incrementAndGet();
|
||||
@ -375,7 +375,7 @@ public class AsyncListenerHandler {
|
||||
|
||||
// Individual shut down is irrelevant now
|
||||
synchronized (stopLock) {
|
||||
notifyAll();
|
||||
stopLock.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren