Threads problems

  • Thread starter Thread starter csharpula csharp
  • Start date Start date
C

csharpula csharp

Hello,
I am trying to build thread inside thread in this way:

Thread A (start)
{
successHandler = false
commandA
commandB
Thread B (start)
if (successHandler)
commandC

Handler B
{
successHandler = true
}
}
Handler A
{
end
}

Somehow I got stucked after HandlerB and commandC is not activated. Why
is that? Thank u!



}
 
First - it is very hard to unpick your intentions from that pseudo-code.
Some genuine (but slimmed down) code would be much more useful.

It is highly unlikely what thread B has done much when you run the
"successHandler" test. What is it you are actually trying to do? If you
need to wait for thread B to get "so far" you will need a wait-handle of
some kind (Monitor, AutoResetEvent, etc).

But it also begs the question of whether thread A could do this bit,
befoer starting thread B (no point it just sitting there...)

Marc
 
Hello,
I am trying to build thread inside thread in this way:

Thread A (start)
{
successHandler = false
 commandA
 commandB
 Thread B (start)
 if (successHandler)
 commandC

 Handler B
{
successHandler = true}
}

Handler A
{
end

}

Somehow I got stucked after HandlerB and commandC is not activated. Why
is that? Thank u!

}

*** Sent via Developersdexhttp://www.developersdex.com***

Hi,

Are you sure you need a thread? (Handler B) ?
From your code it seems that first thread should block until Thread B
ends.
What are you trying to do?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top