G
Guest
I'm writing simulator to help with testing out problems with deadlocking on a
database.
I have a function which I call from a delegate BeginInvoke call, and
depending on the simulation I might have from three to 20 threads running.
here's the function...
void DoTest()
{
for(int jj=0;jj<Y;jj++)
{
for(int ii=0;ii<N;ii++)
{
Work1();
Work2();
}
CleanUp();
}
the threading question, that I can't get my head around, is how do I make
the call to CleanUp() mutually exclusive of everything else.
that is to say I want Work1() and Work2() to be executing in parallel, but
if any thread is running Work1() or Work2(), then CleanUp() can't run, and if
any thread is in CleanUp(), then Work1() and Work2() can't run.
However I don't want a solution which requires all the running threads to
complete the inner loop of work1() and work2().
Any ideas?
database.
I have a function which I call from a delegate BeginInvoke call, and
depending on the simulation I might have from three to 20 threads running.
here's the function...
void DoTest()
{
for(int jj=0;jj<Y;jj++)
{
for(int ii=0;ii<N;ii++)
{
Work1();
Work2();
}
CleanUp();
}
the threading question, that I can't get my head around, is how do I make
the call to CleanUp() mutually exclusive of everything else.
that is to say I want Work1() and Work2() to be executing in parallel, but
if any thread is running Work1() or Work2(), then CleanUp() can't run, and if
any thread is in CleanUp(), then Work1() and Work2() can't run.
However I don't want a solution which requires all the running threads to
complete the inner loop of work1() and work2().
Any ideas?