using System.Collections.Generic;
using System.Collections.Immutable;
class Genome : Queue<char>, IEquatable<Genome>
public bool Equals(Genome other) => this.SequenceEqual(other);
public static void Main()
var dictionary = ImmutableDictionary<int, Genome>.Empty;
CancellationTokenSource cts = new(TimeSpan.FromSeconds(1));
Thread[] threads = Enumerable.Range(1, 2).Select(i => new Thread(() =>
while (!cts.IsCancellationRequested)
Genome genome = ImmutableInterlocked.AddOrUpdate(ref dictionary,
1, _ => new(), (_, _) => new());
lock (genome) genome.Enqueue('A');
Array.ForEach(threads, t => t.Start());
Array.ForEach(threads, t => t.Join());