Thread Safe (TS) and Non Thread Safe (NTS) - What are they, what's the difference?

6

When someone is going to download PHP, you have these 2 options: ts and nts , as well as language extensions. My doubts are as follows:

  • What are Thread Safe and Non Thread Safe (NTS) ?
  • Are there any differences between them?
  • Each is recommended for what kind of development
asked by Vinícius Lima 27.05.2016 в 20:24

1 answer

8

From the PHP documentation:

  

Thread Safety means that the torque can work in a context of   server, such as Apache 2 on Windows. Thread   Safety works by creating a local storage copy   on each segment, so the data does not collide with another segment.

     

So what do I choose? If you choose to run PHP as a   CGI binary, so you will not need thread safety because the   is called on each request. For web servers   multithreaded, such as IIS5 and IIS6, you must use the chained version (   threaded version of PHP.

So, it really depends on the way you want to use PHP:

Apache + LoadModule: thread-safe
Apache + FastCGI: Non-thread-safe
IIS: thread-safe
IIS + FastCGI: Non-thread-safe

The PHP Manual has some very interesting instructions.

Font , Source 2 , Source 3 (Out SO)

    
27.05.2016 / 20:41
python: compare list that contains multiple lists with a different unique list ___ ___ erkimt Is there a difference between using "return" or "exit ()" to end the "main ()"? ______ qstntxt ___

%code% terminates running the application immediately. The %code% command exits the function, but when it is inside the %code% it will exit the application, including the value used in it will be returned to the one who called the application as an error code (zero is ok), as well as the function output.

Of course there is a difference in other functions, where %code% terminates application immediately and the command will return the execution stream to the calling function.

If both do the same thing in the described situation, does either use one or the other?

    
______ azszpr174313 ___

There is an important semantic difference in C ++. The %code% will close the scope and call all pending destructors. If the application is closed, rarely will the call of the destructors produce a different result, but technically it is possible for one of them to do something that is important to the end of the application, or to print relevant information for the user. >

Even though the action looks the same, the %code% function causes a premature exiting of the application. Then execution is terminated almost immediately. %code% finalizes static objects, but not destructors. The %code% and %code% neither does this and it closes on time.

There's a difference even in C if you have functions registered with %code% . These functions will always run no matter how the application is shutting down. But there will be undefined behavior if one of the linked functions in %code% has reference to some data in stack . Something like %code% and %code% . This is especially important in C. documentation

Note that the %code% function is not special and can be called within the application. In this case there will be an important difference since a %code% will not terminate the application, although in the context of the question this would not happen. But understand that if what you wrote will not be called in the operating system and this %code% is part of a module that will be loaded and used in another application, your module will terminate the application and not only your code if you use %code% , %code% will then be the most appropriate in most situations.

A call to %code% can be recursive, although it should not. Of course there is difference in this case, but it falls into what I said in the previous paragraph.

That's why you always have to choose the most semantically correct way . If you want to terminate the application immediately use %code% , otherwise use %code% . Many people say that if %code% is terminating the application, %code% is the most appropriate. Not everyone agrees, especially in C ++. That's why it's good to understand the workings, the implications of each and do not blindly follow rules.

I do not know if it counts as a difference, because it is a function, to use it, you need to use a %code% so that it is available, and if the code unit it contains would not enter the application, the executable will be a bit bigger. The command is always available.

    
___