"Avdi B. Grimm" <avdi / yahoo.com> writes:

> P.S. Does anyone here have any theories on /why/ threads
> are still percieved as such an arcane topic in the UNIX and
> scripting language communities?

One issue is that an interpreter has to make difficult
mutual-exclusion decisions. E.g. in Python, if the global interpreter
lock went away, you had to protect all dictionary lookup, attribute
access, refcounting etc separately. That would introduce an expensive
overhead, even though there would be no contention for accesses most
of the time. So you have to compromise, and then it is difficult to
keep track of what is mutex-protected under what circumstances.

Another issue is portability; things just don't work the same way on
different platforms. E.g. what datatype would you use for a thread ID?

Finally, there is the issue of cancellation: pthreads has a very
primitive to cancellation. E.g. in Python, you'd like to raise an
exception in a thread to cancel it, so that cleanup actions are run
properly. This is simply not possible through pthread_cancel.

Regards,
Martin