-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRnd.cs
More file actions
28 lines (26 loc) · 657 Bytes
/
Rnd.cs
File metadata and controls
28 lines (26 loc) · 657 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SnakeEvo
{
public class Rnd {
private static readonly Random random = new Random();
private static readonly object syncLock = new object();
public static int RandomNumber(int min, int max)
{
lock (syncLock)
{ // synchronize
return random.Next(min, max);
}
}
public static double RandomDouble()
{
lock (syncLock)
{
return random.NextDouble();
}
}
}
}