array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'en', ), 'this' => array ( 0 => 'class.worker.php', 1 => 'Worker', ), 'up' => array ( 0 => 'book.pthreads.php', 1 => 'pthreads', ), 'prev' => array ( 0 => 'thread.start.php', 1 => 'Thread::start', ), 'next' => array ( 0 => 'worker.collect.php', 1 => 'Worker::collect', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/pthreads/worker.xml', ), 'extra_header_links' => array ( 'rel' => 'alternate', 'href' => '/manual/en/feeds/class.worker.atom', 'type' => 'application/atom+xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PECL pthreads >= 2.0.0)
Worker Threads have a persistent context, as such should be used over Threads in most cases.
When a Worker is started, the run method will be executed, but the Thread will not leave until one of the following conditions are met:
the Worker goes out of scope (no more references remain)
the programmer calls shutdown
the script dies
This means the programmer can reuse the context throughout execution; placing objects on the stack of the Worker will cause the Worker to execute the stacked objects run method.