Maxim Vexler wrote:
Doesn't the kernel allocate each thread his own memory spaceNo. In fact, common memory is the major benefit of threads (when compared to e.g. forking a new process).
(including for var's which are global for that thread)?
Global variables which don't get used simultanuously by more than one thread (e.g. some cases where only the "main thread" touches them) are no problem.
However, when more than one thread might access them at the same time, you generally need to apply techniques like semphores or mutex to avoid data corruption.
Should i take extreme measures to avoid using globals in my code ?Some compilers, languages and some free cross-platform utility libraries offer tools to make this sort of thing easy to handle.
If you use C, you might consider "glib"'s thread support:
GLib:Threads:GPrivate <http://developer.gnome.org/doc/API/glib/glib-threads.html#GPRIVATE>
================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
