为什么没有一个ConcurrentList< T>ConcurrentList、LT、GT

2023-09-04 22:42:43 作者:给你一口甜甜

新的命名空间System.Collections.Concurrent包含并发集合了字典,队列和其他类中叠加。任何人都知道为什么它没有ConcurrentList?

The new namespace System.Collections.Concurrent contains concurrent collections for dictionary, queue and stack among other classes. Anyone know why is it that there is no ConcurrentList?

我已经发布了一个新问题,说明我目前的情况。我preferred,要改变原来问题的整体感。这里的the 链接到新的问题。

I've posted a new question explaining my current scenario. I preferred that to changing the whole sense of the original question. Here's the link to the new question.

推荐答案

随机访问不会做出这与另一个线程改变的数据结构太大的意义。

Random access doesn't make much sense on a data structure that's changed from another thread.

如果你看一下并发集合,你会发现,它们的接口是专为多线程访问工作。我想不出一个有用的列表式界面与多线程code行之有效的。

If you look at the concurrent collections, you'll notice that their interface is specifically designed to work well with multi threaded access. I can't think of a useful list-like interface that works well with multithreaded code.

随机多线程访问可能有意义,如果要素未动,但你有一个数组。

Random multi threaded access can make sense if the elements are never moved, but then you have an array.

 
精彩推荐
图片推荐