Assuming I have an object A containing
// ...
private List<double> someList = new List<double>();
// ...
public List<double> SomeList
{
get { lock (this) { return someList; } }
}
// ...
would it be thread safe to perform operation on the list as in the code below. Knowing that several operations could be executed simultaneously by different threads.
A.SomeList.Add(2.0);
or
A.SomeList.RemoveAt(0);
In other words, when is the lock released?
The lock you shown in the question isn’t of much use.
To make list operations thread safe you need to implement your own Add/Remove/etc methods wrapping those of the list.
Also, it’s a good idea to hide the list itself from the consumers of your class, i.e. make the field private.