diff options
author | dasMulli <martin.andreas.ullrich@gmail.com> | 2016-10-13 08:19:52 +0200 |
---|---|---|
committer | dasMulli <martin.andreas.ullrich@gmail.com> | 2016-10-13 08:35:19 +0200 |
commit | d6aadf7ade76b443c74e677ef5030c91b563ceab (patch) | |
tree | 060d7e8851af74919991e746afe2c46904d88176 /src/mscorlib | |
parent | 9f6a0b675e5ac0065a268554de49162c539ff66d (diff) | |
download | coreclr-d6aadf7ade76b443c74e677ef5030c91b563ceab.tar.gz coreclr-d6aadf7ade76b443c74e677ef5030c91b563ceab.tar.bz2 coreclr-d6aadf7ade76b443c74e677ef5030c91b563ceab.zip |
Addressed PR feedback.
Diffstat (limited to 'src/mscorlib')
-rw-r--r-- | src/mscorlib/src/System/Random.cs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/mscorlib/src/System/Random.cs b/src/mscorlib/src/System/Random.cs index cb5da3c543..87440b2d8d 100644 --- a/src/mscorlib/src/System/Random.cs +++ b/src/mscorlib/src/System/Random.cs @@ -56,7 +56,7 @@ namespace System { } /*========================================================================================= - **Action: Initializes a new instance of the Random class, using a the specified seed value + **Action: Initializes a new instance of the Random class, using a specified seed value ===========================================================================================*/ public Random(int Seed) { int ii; @@ -125,21 +125,23 @@ namespace System { [ThreadStatic] private static Random t_threadRandom; - private static Random s_globalRandom = new Random(GenerateGlobalSeed()); + private static readonly Random s_globalRandom = new Random(GenerateGlobalSeed()); /*=====================================GenerateSeed===================================== **Returns: An integer that can be used as seed values for consecutively creating lots of instances on the same thread within a short period of time. ========================================================================================*/ private static int GenerateSeed() { - if (t_threadRandom == null) { + Random rnd = t_threadRandom; + if (rnd == null) { int seed; lock (s_globalRandom) { seed = s_globalRandom.Next(); } - t_threadRandom = new Random(seed); + rnd = new Random(seed); + t_threadRandom = rnd; } - return t_threadRandom.Next(); + return rnd.Next(); } /*==================================GenerateGlobalSeed==================================== |