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 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失