void (@NotNull Thread victimThread) { int interruptsInARow = 0; while (victimThread.isAlive()) { if (!victimThread.isInterrupted()) { victimThread.interrupt(); interruptsInARow++; } if (interruptsInARow >= FileChannelInterruptsRetryer.MAX_RETRIES / 2) { //We need to interrupt thread often enough to catch it mid-IO-operation, but not so often // that we trigger 'too many retries' (current limit: 64 per op). Hence, the pause here: // give current IOop a chance to complete and reset retry counter: LockSupport.parkNanos(100_000); } } }