Thread-safe: It is used to ensure that when the shared data structure which is manipulated by different threads are prevented from entering the race condition. Thread-safety is recommended when the web server run multiple threads of execution simultaneously for different requests. In Thread Safety binary can work in a multi-threaded web server context. Thread Safety works by creating a local storage copy in each thread so that the data will not collide with another thread.
- Apache + LoadModule
Non-thread-safe: It does not check the safety of the threads which makes it faster to run but at the same time, it becomes more unstable and crashes very frequently. It refers to a single thread only builds. In non-thread safe version binaries widespread use in the case of interaction with a web server through the FastCGI protocol, by not utilizing multi-threading.
- Apache + FastCGI
- IIS + FastCGI
So it depends on the way that you want to use PHP. AFAIR running PHP with the fastCGI is the preferable way. If you are unknown which version of PHP is installed in your system then there is an easy way to know that.
Check the version of installed PHP Thread safe or Non Thread Safe:
Open a phpinfo() and search for the line Thread safety for a thread-safe build you should find enable.
- On Windows:
php -i|findstr "Thread"
- On *nix:
php -i|grep Thread
- In the both cases will display any one
Thread Safety => enabled //or Thread Safety => disabled
- Python | Different ways to kill a Thread
- Top 10 Projects For Beginners To Practice HTML and CSS Skills
- Vue.js | Introduction & Installation
- PHP | Gmagick current() Function
- PHP | Gmagick getimageredprimary() Function
- PHP | Gmagick getimagetype() Function
- Node.js | util.types.isWeakSet() Method
- Node.js | Buffer.writeInt16BE() Method
- Node.js | util.types.isMap() Method
- Node.js | dnsPromises.resolveAny() Method
- PHP | Gmagick getimagedelay() Function
- PHP | Gmagick getsize() Function
- PHP | Gmagick levelimage() Function
- Node.js | os.arch() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.