If you are working with a large List (lets say 1GB in size), and it needs to be resized to make room for additional items. Is it possible to read/write to that list while it is being resized, or is the call going to be bocked until the operation is finished?
Share
You say “1GB in size” but what does this actually mean? Bear in mind that if you’re working with a reference type, all that will be in the list itself is a bunch of references – so the bulk of the memory taken up by “a list and all its elements” is going to be in the elements themselves, unless you have a lot of duplicate references.
Now, as to your question itself –
List<T>isn’t threadsafe. You shouldn’t be trying to read it while it’s being modified in another thread. If you need to work with a list in multiple threads, with some of them modifying it, you should use locking to make sure that only one thread accesses it at time (or perhaps multiple threads reading, but not writing).