dsxml2169 2016-05-26 09:54 采纳率: 0%
浏览 114
已采纳

PHP中是否存在两个静态方法的并行调用?

What will happen if same static method is called by two parallel threads?

Will it make one thread waiting or can two parallel instances of a static method exists?

Assume function don't use member variables and only use local variables.

Example:

<?php

    public class ClassName{

        public static function doStuff(){
            // Function code goes here
        }
    }

?>

Assume this function is called by GET request to the server. Then if two users send a call to the URL exactly at same time, then what will happen?

  • 写回答

1条回答 默认 最新

  • dslfq06464 2016-05-26 10:31
    关注

    See Confirmation that PHP static variables do not persist across requests for the information you need.

    Standard PHP does not do any locking or waiting. It will just run the method and the 2 seperate request do not known of each other and they can't access each others memory(In the given case).

    This is a race condition. It depends which request gets processed first. A http request is handled by a webserver and the webserver spawns a php process to process the php script.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用
  • ¥15 kafka topic 所有分副本数修改
  • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?
  • ¥40 串口调试助手打开串口后,keil5的代码就停止了