Don Bruder <net> wrote:
You are using the "Thread Manager" which only supports Cooperative
Threads. This means that you are pretty much allowed to do anything you
want from within the thread. No need to worry about interrupt time, etc.
You are probably thinking that your thread will be running preemptively,
in which case, you *DO* need to worry about routines which are
thread-safe. But to use Preemptive Threads you need to use the
Multi-Processing API's or PThreads (Under MacOS X).
Not really. When you call NewThread, you are setting up a thread to be
ready to execute the next time you call YieldToAnyThread (or
It does not execute as soon as NewThread is called.
It finishes executing when your thread-entry function exits.
Typically, you'd have a loop in your thread-entry function which
performs some long-ish task. Inside this loop, you'd call
YieldToAnyThread to give up the CPU to other threads.
Not really. The thing about threads is that within the same application,
they all share the same memory space and have complete access to any
global memory that any other thread in the same application has access
They do each have their own run-time stacks though, which allows them to
behave independantly as long as they don't get in each other's way.
You have to keep in mind that when dealing with cooperative threads, you
have to sprinkle calls to YieldToAnyThread through your code.
This is what allows other cooperative threads to have the CPU.
It doesn't work like Preemtive Threads where this is handled
automatically for you.
I'm sure you will receive replies telling you that the Thread Manager is
depricated and you should be using the multiprocessing API's instead.
It is NOT depricated. It is completely supported under MacOS X.
But both types of threads are useful under different cirstances.