aftermath to 6ef57221e3: avoiding NPE when waiting for listener thread

This commit is contained in:
Axel Uhl committed 2023-07-14 22:17:51 +02:00
1 parent 475db734e4
commit 63bbfb1a9f
1 file changed
+5 -4
@@ -200,13 +200,14 @@ public class MarkPassingCalculator {
*/
public void waitUntilStopped(final long timeoutInMillis) throws InterruptedException {
final long start = System.currentTimeMillis();
if (listenerThread != null) {
synchronized (listenerThread) {
final Thread theListenerThread = listenerThread;
if (theListenerThread != null) {
synchronized (theListenerThread) {
while (!listenerThreadStarted && System.currentTimeMillis() - start < timeoutInMillis) {
listenerThread.wait(timeoutInMillis);
theListenerThread.wait(timeoutInMillis);
}
}
listenerThread.join(timeoutInMillis);
theListenerThread.join(timeoutInMillis);
}
}