/// <summary> /// Gets an instance from the pool. /// </summary> /// <returns>An instance of <typeparamref name="T"/>.</returns> public T Get(Thread thread) { MyConcurrentQueue <T> queue; if (!m_instances.TryGetValue(thread, out queue)) { queue = new MyConcurrentQueue <T>(); m_instances.Add(thread, queue); } T instance; if (!queue.TryDequeue(out instance)) { instance = new T(); } return(instance); }