Thread Object和Worker Object(php pthreads)有什么区别 [英] What is the difference between Thread Object and Worker Object (php pthreads)

查看:90
本文介绍了Thread Object和Worker Object(php pthreads)有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我发现的唯一解释是: http://pthreads.org

The only explanation that I've found so far is here: http://pthreads.org

但这在代码方面意味着什么?什么时候应该使用Worker,什么地方应该使用Threads?

But what does that mean in terms of code? When should I use Worker(s) and where should I use Threads?

谢谢!

推荐答案

它们都是线程,但是,线程旨在执行一个任务(在其run方法中定义),然后退出. Worker旨在等待可堆叠派生对象形式的任务,实现自己的运行方法,并按插入顺序从堆栈中执行它们.

They are both Threads, but, a Thread is intended to execute one task ( that defined in it's run method ) and then exit. A Worker is intended to wait for tasks, in the form of Stackable derived objects, implementing their own run methods and execute them from a stack in the order they are inserted.

通过这种方式,Worker允许您重用上下文,它们提供了一种效率很高的方法,很难在用户区进行编程,但是没有什么不可能的.

In this way, the Worker allows you to reuse a context, they provide a means of efficiency quite difficult to program in userland, but nothing like impossible.

这篇关于Thread Object和Worker Object(php pthreads)有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆