【问题标题】:Are PHP pthreads the same as the POSIX threads?PHP pthreads 与 POSIX 线程相同吗?
【发布时间】:2013-04-28 02:09:32
【问题描述】:

我找到了对 pthreads 的引用,以便在 PHP 中进行新的线程处理: http://php.net/manual/en/book.pthreads.php

但是当我用谷歌搜索 pthreads 时,只会出现 POSIX 线程的引用,它们缩写为 pthreads。它们是一样的吗?

【问题讨论】:

  • 检查链接@MarcB。这是新的。 “pthreads 是一个面向对象的 API,它允许 PHP 中的用户级多线程”。只是想知道它是否与 POSIX 线程相同或相关。
  • 但是 PHP pthread 是 POXIS 线程的扩展,对吧?
  • @MarcB - 你真的确定你评论的是事实吗?谷歌搜索一些与 php 和线程相关的短语我偶然发现了这个链接,你写的似乎是不正确的,并且与 Joe Watkins 所说的直接冲突。您能否确认您的声明或将评论标记为已过时以避免其他访问者混淆?

标签: php pthreads posix


【解决方案1】:

pthreads 是 PHP 的用户态线程 API,基于 Posix 线程,在 windows 上由 pthread-w32 支持。

http://pthreads.org

【讨论】:

  • + 我认为更多不同的例子会有所帮助
【解决方案2】:

据我了解,这个 PHP 扩展使 PHP 可以使用系统 pthreads(POSIX 线程),即一个包装器加上一些额外的点点滴滴,以将其集成到 php 中。

正如您在此处看到的,在他们的扩展源代码中,Thread::start() 使用 POSIX pthread_create()

简而言之,您的问题的答案是“是”。这是 PHP 中正确的 POSIX 线程。示例在他们的页面上:http://pthreads.org/tutorials/start.html 并在 github 仓库中:https://github.com/krakjoe/pthreads/tree/master/examples

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多