Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find if the installed PHP is threadsafe or nonthreadsafe?

How do I find out whether the installed version of PHP is threadsafe or not thread safe?

Please note that I'm not asking the difference between a threadsafe/non thread safe installation. I would like to find out what is installed currently.

like image 432
Josh Avatar asked Apr 27 '11 05:04

Josh


People also ask

How do I make sure a method is thread-safe?

There is no rule that makes the code thread safe, the only thing you can do is make sure that your code will work no matter how many times is it being actively executed, each thread can be interrupted at any point, with each thread being in its own state/location, and this for each function (static or otherwise) that ...

What is the difference between NTS and TS?

The difference of NTS and TS is in the name itself. TS = Thread Safe. NTS = Non Thread Safe. Though the non checking of thread safty the NTS version is a very little faster.

What is not thread-safe mean?

Not thread safe: Data structures should not be accessed simultaneously by different threads.


2 Answers

Open a phpinfo() and search for the line Thread safety. For a thread-safe build you should find enable.

As specified in the comments by Muhammad Gelbana you can also use:

  • On Windows : php -i|findstr "Thread"
  • On *nix: php -i|grep Thread
like image 61
grunk Avatar answered Oct 13 '22 17:10

grunk


If you prefer to use the command line:

  • *nix:

    php -i | grep -i "Thread" 
  • Windows:

    php -i | findstr -i "thread" 

This should give you something like this:

Thread Safety => enabled 

or

Thread Safety => disabled 
like image 20
Matt Avatar answered Oct 13 '22 18:10

Matt