Why is PHP not thread safe?

Well a while ago I requested that pthreads be integrated with PHP in the next version, looks like its not gonna happen and the primary reason is that PHP is not thread safe.

But I dont understand why the default way PHP is installed/bundled on Unix system is not thread-safe, anyone mind elaborating? Also lets say if I run my own PHP on a dedicated hosting environment and that the PHP can be customized, how can I make PHP thread-safe? Or is it not achievable?

Well what is being said here, is that the DEFAULT installation is not thread safe. If you go to the downloads page, you will see two options, thread safe and non thread safe. But in reality, thread safe isnt even truely thread safe (I have not looked too far into pthreads as it was fairly new when I was researching). Think about when PHP was developed and what for. It’s hard to conceive that PHP would ever have a need to be thread safe, and now the language is too old / far along / messed up to allow for it to truely be thread safe without a full re write (which will not happen). If you want basic “thread safe” installation, goto the downloads page and install the thread safe version of php, then install pthreads using pecl.

I too was annoyed with the lack of ability to create threads or at the very least processes with the ability to exchange information between them easily. I’ve since begun moving away in favor of other languages. PHP definitely has its place (for now) but like every language, it has short comings and situations in which it’s not best suited for, threaded operations is close to that line.

May I ask what type of projects you are working on that has you interested in threading?