mirror of
https://github.com/sphildreth/roadie
synced 2025-02-27 12:47:15 +00:00
18 lines
No EOL
457 B
C#
18 lines
No EOL
457 B
C#
using System;
|
|
using System.Threading;
|
|
|
|
namespace Roadie.Library.Utility
|
|
{
|
|
public static class StaticRandom
|
|
{
|
|
private static readonly ThreadLocal<Random> threadLocal = new ThreadLocal<Random> (() => new Random(Interlocked.Increment(ref seed)));
|
|
|
|
private static int seed;
|
|
public static Random Instance => threadLocal.Value;
|
|
|
|
static StaticRandom()
|
|
{
|
|
seed = Environment.TickCount;
|
|
}
|
|
}
|
|
} |