P
Phillip N Rounds
I'm cursed by being a linear thinker.
Anyway, I have an application (service) where I can't decide on the
appropriate way to implement threading.
I have a timer which periodically initiates Process A
Process A does something, then has to call N instances of Process B, where N
varies from instance to instance of Process A.
Process B then has to call M(n) instances of Process C, for each n < N,
where again the # of instances of Process C varies for each call to process
B.
Clearly, I can do the following: ( process A & B are really in seperate
worker classes, but this is a simplified version)
Main Class
OnTimer( )
{
int N = CalculateNumberOfProcessARequirements();
for ( int i = 0; i < N; i++) {
Thread t = new Thread( new ThreadStart( this.ProcessA);
t.Start(); }
return;
}
ProcessA()
{
int M = CalculateNumberOfProcessBRequirements();
for ( int i = 0; i < M; i++) {
Thread t = new Thread( new ThreadStart( This.ProcessB) }
return;
}
ProcessB()
{
DoTheActualWork();
return;
}
My question is, how do I do the book-keeping.
Anyway, I have an application (service) where I can't decide on the
appropriate way to implement threading.
I have a timer which periodically initiates Process A
Process A does something, then has to call N instances of Process B, where N
varies from instance to instance of Process A.
Process B then has to call M(n) instances of Process C, for each n < N,
where again the # of instances of Process C varies for each call to process
B.
Clearly, I can do the following: ( process A & B are really in seperate
worker classes, but this is a simplified version)
Main Class
OnTimer( )
{
int N = CalculateNumberOfProcessARequirements();
for ( int i = 0; i < N; i++) {
Thread t = new Thread( new ThreadStart( this.ProcessA);
t.Start(); }
return;
}
ProcessA()
{
int M = CalculateNumberOfProcessBRequirements();
for ( int i = 0; i < M; i++) {
Thread t = new Thread( new ThreadStart( This.ProcessB) }
return;
}
ProcessB()
{
DoTheActualWork();
return;
}
My question is, how do I do the book-keeping.