Skip to content

Commit

Permalink
Merge pull request #16922 from mkouba/issue-16875
Browse files Browse the repository at this point in the history
Fix the shutdown hook of the main executor for blocking tasks
  • Loading branch information
mkouba authored May 3, 2021
2 parents 5a7a74d + ef7e86c commit 1d32f5e
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ public void run() {
long interruptRemaining = threadPoolConfig.shutdownInterrupt.toNanos();

long start = System.nanoTime();
for (;;)
int loop = 1;
for (;;) {
// This log can be very useful when debugging problems
log.debugf("loop: %s, remaining: %s, intervalRemaining: %s, interruptRemaining: %s", loop++, remaining,
intervalRemaining, interruptRemaining);
try {
if (!executor.awaitTermination(Math.min(remaining, intervalRemaining), TimeUnit.NANOSECONDS)) {
long elapsed = System.nanoTime() - start;
Expand Down Expand Up @@ -109,10 +113,12 @@ public void run() {
break;
}
}
} else {
return;
}
return;
} catch (InterruptedException ignored) {
}
}
}
};
}
Expand Down

0 comments on commit 1d32f5e

Please sign in to comment.