pthreads overrides the functionality of the protected and private method modifiers in order to provide functionality more suited to multi-threaded objects.
pthreads applies this functionality to all Thread, Worker and Stackable objects from creation.
</para>
<example>
<title>protected method example: protected methods can only be executed by one Thread at a time.</title>
<programlistingrole="php">
<![CDATA[
<?php
class ExampleThread extends Thread {
public function run() {
/* thread code */
if ($this->synchronized()) {
}
}
protected function synchronized() {
/* synchronized method */
}
}
$thread = new ExampleThread();
if ($thread->start()) {
$thread->synchronized();
}
?>
]]>
</programlisting>
</example>
<example>
<title>private method example: private methods may only be executed by the Thread, Worker, or Stackable during execution</title>