diff options
Diffstat (limited to 'src/mscorlib/src/System/Collections/Concurrent/ConcurrentStack.cs')
-rw-r--r-- | src/mscorlib/src/System/Collections/Concurrent/ConcurrentStack.cs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/mscorlib/src/System/Collections/Concurrent/ConcurrentStack.cs b/src/mscorlib/src/System/Collections/Concurrent/ConcurrentStack.cs index 10a5201f6c..82bc4f9f5c 100644 --- a/src/mscorlib/src/System/Collections/Concurrent/ConcurrentStack.cs +++ b/src/mscorlib/src/System/Collections/Concurrent/ConcurrentStack.cs @@ -135,7 +135,7 @@ namespace System.Collections.Concurrent { get { - throw new NotSupportedException(Environment.GetResourceString("ConcurrentCollection_SyncRoot_NotSupported")); + throw new NotSupportedException(SR.ConcurrentCollection_SyncRoot_NotSupported); } } @@ -306,7 +306,6 @@ namespace System.Collections.Concurrent result = default(T); return false; - } /// <summary> @@ -328,7 +327,7 @@ namespace System.Collections.Concurrent Node head; Node next; int backoff = 1; - Random r = new Random(Environment.TickCount & Int32.MaxValue); // avoid the case where TickCount could return Int32.MinValue + Random r = null; while (true) { head = m_head; @@ -359,7 +358,18 @@ namespace System.Collections.Concurrent spin.SpinOnce(); } - backoff = spin.NextSpinWillYield ? r.Next(1, BACKOFF_MAX_YIELDS) : backoff * 2; + if (spin.NextSpinWillYield) + { + if (r == null) + { + r = new Random(); + } + backoff = r.Next(1, BACKOFF_MAX_YIELDS); + } + else + { + backoff *= 2; + } } } |