Code clean-up

Motivation:

It is less confusing not to spread Thread.interrupt() calls.

Modification:

- Comments
- Move generatorThread.interrupt() to where currentThread.interrupt() is
  triggered

Result:

Code that is easier to read
This commit is contained in:
Trustin Lee 2014-04-25 17:42:00 +09:00
parent 0fceef8ab6
commit 1492b32da7

View File

@ -131,7 +131,6 @@ public class ThreadLocalRandom extends Random {
}
} catch (InterruptedException e) {
interrupted = true;
generatorThread.interrupt();
logger.warn("Failed to generate a seed from SecureRandom due to an InterruptedException.");
break;
}
@ -144,8 +143,12 @@ public class ThreadLocalRandom extends Random {
ThreadLocalRandom.initialSeedUniquifier = initialSeedUniquifier;
if (interrupted) {
// restore interrupt status because we don't know how to/don't need to handle it here
// Restore the interrupt status because we don't know how to/don't need to handle it here.
Thread.currentThread().interrupt();
// Interrupt the generator thread if it's still running,
// in the hope that the SecureRandom provider raises an exception on interruption.
generatorThread.interrupt();
}
}