Why is List not thread-safe?

前端 未结 6 1559
醉梦人生
醉梦人生 2020-12-04 15:28

From the following site:

http://crfdesign.net/programming/top-10-differences-between-java-and-c

Unfortunately, List<> is no

6条回答
  •  既然无缘
    2020-12-04 16:21

    Why would it be thread-safe? Not every class is. In fact, by default, classes are not thread-safe.

    Being thread-safe would mean that any operation modifying the list would need to be interlocked against simultaneous access. This would be necessary even for those lists that will only ever be used by a single thread. That would be very inefficient.

提交回复
热议问题