gpt4 book ai didi

php - 为 PHP 版本 5.6.2 启用线程安全

转载 作者:太空宇宙 更新时间:2023-11-04 03:49:25 25 4
gpt4 key购买 nike

我在我的 Linux 服务器上安装了以下 php 版本。

enter image description here

现在我想运行下面的程序 -

<?php
class AsyncOperation extends Thread {

public function __construct($arg) {
$this->arg = $arg;
}

public function run() {
if ($this->arg) {
$sleep = mt_rand(1, 10);
printf('%s: %s -start -sleeps %d' . "\n", date("g:i:sa"), $this->arg, $sleep);
sleep($sleep);
printf('%s: %s -finish' . "\n", date("g:i:sa"), $this->arg);
}
}
}

// Create a array
$stack = array();

//Iniciate Miltiple Thread
foreach ( range("A", "D") as $i ) {
$stack[] = new AsyncOperation($i);
}

// Start The Threads
foreach ( $stack as $t ) {
$t->start();
}
?>

我需要为我的 php 安装启用线程安全。有人可以告诉我该怎么做吗?

最佳答案

好的,I asked the package maintainer :

If you want to use threaded version of PHP, you are on your own. While it might work just fine in a specific environment, it's not thread-safe in all possible scenarios (including loading external modules) and thus it's not wise to provide "thread-safe" packages for general use.

所以,没有出路:-/

关于php - 为 PHP 版本 5.6.2 启用线程安全,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26901978/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com