[quoted text, click to view] vooose wrote:
> Thanks for your reply. You are saying that as soon as T1.Start() is
> called, and then T2.Start() after, T2 could even execute its first line
> of code before T1?
>
> ie even putting a lock on the very first line won't help me!
If you need inter-thread synchronization, you can't rely on critical
sections, you need to use signalling.
If your T1 and T2 threads are related, in such a way that T1 absolutely
must execute some piece of code before T2 get to it, then you need to
add code to both threads that guarantee that. For instance, you could
create an event object that is initially unsignalled, let T2 wait for
the event to become signalled, and let T1 signal the event when it has
completed the block of code that has to execute before T2 continues.
Throwing a few items into the thread pool will not in any way guarantee
anything about their order. Sure, the thread pool might be implemented
in such a way that it doles out the work objects to the threads in the
order it receives them, but the way the thread system works will make
these threads seem to run pretty random, ie. T1 will execute a bit, T2
will execute a bit, T7 will execute a bit, T5 will execute a bit, etc.
--
Lasse Vågsæther Karlsen
http://www.vkarlsen.no/ mailto:lasse@vkarlsen.no