Change language

What is thread safe or not thread safe in PHP?

Thread Safe:it is used to ensure that when a shared data structure manipulated by different threads cannot get into a race condition. Thread safety is recommended when the web server runs multiple threads of execution at the same time for different requests. The Thread Safety binary can run in the context of a multithreaded web server. Thread safety works by making a copy of local storage in each thread so that data does not collide with another thread. 
For example :
  • Apache + LoadModule
  • IIS
Not threaded -oriented:it does not check for thread safety, which makes it faster, but at the same time it becomes more unstable and crashes very often. This only applies to one thread. In the non-threaded version, binaries are widely used when communicating with a web server using the FastCGI protocol, without using multithreading. 
For example :
  • Apache + FastCGI
  • IIS + FastCGI
So this depends on how you want to use PHP. AFAIR running PHP with fastCGI is the preferred way. If you don’t know what version of PHP is installed on your system, there is an easy way to find out. 
Check the version of PHP Thread Safe or Non Thread Safe installed:
Open phpinfo() and find the Thread thread line for multithreaded build, which you should find enable.
  • On Windows:
    php -i | findstr "Thread" 
  • On * nix:
    php -i | grep Thread 
  • In both cases, any
    Thread Safety = > enabled // or Thread Safety = > disabled 


Best laptop for Sims 4


Best laptop for Zoom


Best laptop for Minecraft


Best laptop for engineering student


Best laptop for development


Best laptop for Cricut Maker


Best laptop for hacking


Best laptop for Machine Learning


Latest questions


psycopg2: insert multiple rows with one query

12 answers


How to convert Nonetype to int or string?

12 answers


How to specify multiple return types using type-hints

12 answers


Javascript Error: IPython is not defined in JupyterLab

12 answers



Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method