Dont deadlock
This commit is contained in:
@@ -53,12 +53,18 @@ public class SectionSavingService {
|
|||||||
|
|
||||||
//Hard limit the save count to prevent OOM
|
//Hard limit the save count to prevent OOM
|
||||||
if (this.getTaskCount() > 5_000) {
|
if (this.getTaskCount() > 5_000) {
|
||||||
while (this.getTaskCount() > 5_000) {
|
//wait a bit
|
||||||
try {
|
try {
|
||||||
Thread.sleep(10);
|
Thread.sleep(10);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
//If we are still full, process entries in the queue ourselves instead of waiting for the service
|
||||||
|
while (this.getTaskCount() > 5_000 && this.threads.isAlive()) {
|
||||||
|
if (!this.threads.steal()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.processJob();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user