On Jul 31, 2008, at 8:49 AM, Miller, James T. wrote:
1- If I run multiple threads (2 or 3) on a Mac with 4 CPUs, does
each thread
execute on its own CPU, i.e., is there a processing boost to using
threads
in this case.
No, they are cooperative threads and run on a single core (and have
the benefit of not crashing if you call anything not threadsafe, such
as most of the UI functions in the OS.)
2 - What happens if a thread (or several threads) calls a method
that is not
in the thread, e.g., a method defined in the window class that
initiated the
thread?
It doesn't matter what it calls. The thread is the code in the Run
event and anything that Run event calls, directly or indirectly. It
doesn't matter where that code lives in your project; it's being run
as a separate thread if it's being called from code that's running as
a separate thread.
In particular, are such methods re-enterant, i.e., if one thread
calls the method while the other is still using the same method,
will the
processing in the method execute properly for both calls (seems to
in my
testing).
Yes. Of course if the method accesses anything other than local
variables (such as static variables, globals, object properties,
etc.), then the two instances of the method may still communicate, and
your definition of "execute properly" will become important.
Best,
- Joe
--
Joe Strout
Inspiring Applications, Inc.
http://www.InspiringApps.com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
|