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 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置