A
Akula
Does anyone know whether or not it is faster to lock a simple object,
rather than a complex type?
For example:
Dictionary<string, SomeOtherClass> dict = new Dictionary<string,
SomeOtherClass>();
object lockObject = new object();
--- Example 1 ---
lock (dict)
{
// Do something with dict
}
--- Example 2 ---
lock (lockObject)
{
// Do something with dict
}
I have seen a improvment in performance in the simple object locking
v.s. locking the entire dictionary, but what are the side affects?
And why am I seeing that improvment in the first place?
Thanks
rather than a complex type?
For example:
Dictionary<string, SomeOtherClass> dict = new Dictionary<string,
SomeOtherClass>();
object lockObject = new object();
--- Example 1 ---
lock (dict)
{
// Do something with dict
}
--- Example 2 ---
lock (lockObject)
{
// Do something with dict
}
I have seen a improvment in performance in the simple object locking
v.s. locking the entire dictionary, but what are the side affects?
And why am I seeing that improvment in the first place?
Thanks