public void TestTableMultithreaded() { var local = new PeerId("Random Local Peer"); var m = new Metrics(); var rt = new RoutingTable(20, DhtId.ConvertPeerId(local), TimeSpan.FromHours(1), m); var peers = Enumerable.Range(0, 500) .Select(i => new PeerId($"Random Peer {i}")) .ToArray(); var t1 = Task.Factory.StartNew(() => { var rand = new Random(Environment.TickCount); for (var i = 0; i < 1000; i++) { var n = rand.Next(peers.Length); rt.Update(peers[n]); } }); var t2 = Task.Factory.StartNew(() => { var rand = new Random(Environment.TickCount); for (var i = 0; i < 1000; i++) { var n = rand.Next(peers.Length); rt.Update(peers[n]); } }); var t3 = Task.Factory.StartNew(() => { var rand = new Random(Environment.TickCount); for (var i = 0; i < 1000; i++) { var n = rand.Next(peers.Length); rt.Find(peers[n]); } }); Task.WaitAll(t1, t2, t3); }