title: PHP Pthreads. "Class Threaded not found"
body: <p>I'm beginner in multithread in PHP with pthreads. I try to run some demo code to understand basics. 
  So, I've installed pthreads:</p>
  
  <pre><code># php -m | grep pthreads
  pthreads
  
  # php -v
  PHP 5.4.45 (cli) (built: Sep 25 2015 08:01:30)
  </code></pre>
  
  <p>I want to run few threads that connect to DB and make query, but using one shared  mysqli object. I run this code:</p>
  
  <pre><code>&lt;?php
  
  class SQLWorker extends Worker {
  
      public function __construct($hostname, $username, $password, $database, $port = 3306) {
          $this-&gt;hostname = $hostname;
          $this-&gt;username = $username;
          $this-&gt;password = $password;
          $this-&gt;database = $database;
      }
  
      public function run() {
          /* the static class scope acts as a kind of thread local storage for this class */
          self::$connection = new MySQLi
          ($this-&gt;hostname, $this-&gt;username, $this-&gt;password, $this-&gt;port);
      }
  
      public function getConnection() {
          return self::$connection;
      }
  
      protected $hostname;
      protected $username;
      protected $password;
      protected $database;
      protected $port;
  
      protected static $connection;
  }
  
  class SQLTask extends Threaded {
      public function __construct($sql) {
          $this-&gt;sql = $sql;
      }
  
      public function run() {
          /* fetch static (thread local) connection */
          $link = $this-&gt;worker-&gt;getConnection();
  
          if ($link) {
              /* execute query, keep result in local scope */
              $result = $link-&gt;query($this-&gt;sql);
  
              /* build up results as normal array */
              while (($row = $result-&gt;fetch_assoc())) {
                  $rows[] = $row;
              }
          }
  
          /* store results in a fetchable form */
          $this-&gt;rows = $rows;
      }
  
      public function getResults() {
          return $this-&gt;rows;
      }
  }
  
  $pool = new Pool(4,
      SQLWorker::connection,
      ["localhost", "username", "password", "database"]);
  
  $pool-&gt;submit(
      $task = new SQLTask("SELECT 1"));
  
  $pool-&gt;shutdown();
  
  /* you have your normal array of data here */
  var_dump($task-&gt;getResults());
  </code></pre>
  
  <p>And get error:</p>
  
  <pre><code>PHP Fatal error:  Class 'Threaded' not found in pThreads.php on line 31
  </code></pre>
  
  <p>Where is my problem?</p>