RandomUtil
using System;
using System.Runtime.CompilerServices;
using System.Threading;
namespace Polly.Utils
{
    [NullableContext(1)]
    [Nullable(0)]
    internal sealed class RandomUtil
    {
        private readonly ThreadLocal<Random> _random;
        public static readonly RandomUtil Instance = new RandomUtil(null);
        public RandomUtil(int? seed)
        {
            _random = new ThreadLocal<Random>(delegate {
                if (seed.HasValue)
                    return new Random(seed.Value);
                return new Random();
            });
        }
        public double NextDouble()
        {
            return _random.Value.NextDouble();
        }
        public int Next(int maxValue)
        {
            return _random.Value.Next(maxValue);
        }
    }
}