用10个工作线程执行1000个任务


Execute 1000 tasks with 10 worker threads

我有1000个任务,我想使用pthread和10个正在运行的worker来处理这些任务。由于PHP没有自己的多线程,所以我想到使用pthreads。

我认为最好的方法是使用pthreads Pool。现在我想知道如何在代码方面做到这一点。我没有任何使用pthreads的经验,我在网上找到的所有Pool示例都不能在我的服务器上工作。特别是那些在pthreads Github页面抛出这个错误:

致命错误:类'Collectable'未找到

对于错误

    Fatal error: Class 'Collectable' not found

我在perl中遇到了同样的问题,如果你使用github的repo,它在这里是好的:

    $ git clone https://github.com/krakjoe/pthreads lib-pthreads
    $ phpize
    $ ./configure
    $ make

我不知道你想要什么。你想知道是什么导致错误(不提供任何细节),或者你应该如何用…将军?