M
Mrinal Kamboj
Hi ,
I had a doubt regarding a piece of code with me , that has to do with
System.Threading.Thread class .
In it user instantiates an array of Thread class and to all of them
assign a method for execution using ThreadStart Delegate say "worker"
method .
Now in the worker method there's a piece of code :
lock (typeof(<ClassName>))
{
try
{
Thread.CurrentThread.Name = AppDomain.GetCurrentThreadId().ToString();
}
catch (System.Exception ex)
{
// Exception code
}
}
where as you can see there's a Synchronized region been created using
lock keyword .
However , what i think is , this is not required since , Worker method
is an instance method and every thread will execute it's own separate
method , so , there's no need , but then another point is all this code
is as a part of an exe , which has only one instance created at any
point of time , so it seems may be required even .
Any comments regarding this ?
thanks ,
Mrinal
I had a doubt regarding a piece of code with me , that has to do with
System.Threading.Thread class .
In it user instantiates an array of Thread class and to all of them
assign a method for execution using ThreadStart Delegate say "worker"
method .
Now in the worker method there's a piece of code :
lock (typeof(<ClassName>))
{
try
{
Thread.CurrentThread.Name = AppDomain.GetCurrentThreadId().ToString();
}
catch (System.Exception ex)
{
// Exception code
}
}
where as you can see there's a Synchronized region been created using
lock keyword .
However , what i think is , this is not required since , Worker method
is an instance method and every thread will execute it's own separate
method , so , there's no need , but then another point is all this code
is as a part of an exe , which has only one instance created at any
point of time , so it seems may be required even .
Any comments regarding this ?
thanks ,
Mrinal