R
Robert May
I have a windows service that spawns multiple threads running a thing that
does a bunch of processing. Here's the code that spawns the threads:
m_totalThreads=Convert.ToInt32(Settings.GetSetting("ProcessorThreads"));
m_executingThreads=new Thread[m_totalThreads];
for (int i=0;i < m_totalThreads;i++)
{
ProcessManager processor=new ProcessManager();
m_executingThreads=new Thread(new ThreadStart(processor.Process));
m_executingThreads.Name=i.ToString();
m_executingThreads.Start();
}
I haven't done a lot of multi-threaded stuff in the past, so I want to make
sure that I get this right.
My question is the following: Because I'm creating a new instance of the
ProcessManager for each thread, will I have problems with the classes that
the process manager spawns? Basically, do I need to worry about locking
instance variables in classes called by the processes manager that runs on
each thread?
Robert
does a bunch of processing. Here's the code that spawns the threads:
m_totalThreads=Convert.ToInt32(Settings.GetSetting("ProcessorThreads"));
m_executingThreads=new Thread[m_totalThreads];
for (int i=0;i < m_totalThreads;i++)
{
ProcessManager processor=new ProcessManager();
m_executingThreads=new Thread(new ThreadStart(processor.Process));
m_executingThreads.Name=i.ToString();
m_executingThreads.Start();
}
I haven't done a lot of multi-threaded stuff in the past, so I want to make
sure that I get this right.
My question is the following: Because I'm creating a new instance of the
ProcessManager for each thread, will I have problems with the classes that
the process manager spawns? Basically, do I need to worry about locking
instance variables in classes called by the processes manager that runs on
each thread?
Robert