title: PHP pthreads works strange
body: <p>sorry for my twisted english - it is not my native.</p>
  
  <p>I have a trouble: pthreads works, but in some strange way: for example, I cannot do "echo" from a thread.<br/>
  Some example code from the internet:
    </p>
  
  <pre><code>&lt;?php
      ini_set('display_errors',E_ALL);
      class hashThread extends Thread {
      private $max = 1;
      private $index = 0;
      function __construct($max, $index)
      {
          $this-&gt;max = $max;
          $this-&gt;index = $index;
      }
      public function run()
      {
          for ($i=1; $i&lt;=$this-&gt;max; $i++)
          {
              md5($i);
          }
          error_log("Thread #{$this-&gt;index} finished\r\n");
          echo "Thread #{$this-&gt;index} finished\r\n";
      }
      }
      $thread_count = 8;
      $start_time = microtime(true);
      for($i=1; $i&lt;=$thread_count; $i++)
      {
      $thread[$i] = new hashThread(1e6, $i);
      $thread[$i]-&gt;start(PTHREADS_INHERIT_NONE);
      }
      echo "Done in: " . round(microtime(true) - $start_time, 2) . " seconds";
  ?&gt;
  </code></pre>
  
  <p>Script shows only "Done in: 0.14 seconds" (in webpage), no echoes, But! it is in error log:</p>
  
  <pre>
  $ tail -f /var/log/nginx/error_log | grep Thread
  2014/03/07 08:05:10 [error] 12621#0: *2818394 FastCGI sent in stderr: "PHP message: Thread #2 finished" ...
  2014/03/07 08:05:10 [error] 12621#0: *2818394 FastCGI sent in stderr: "PHP message: Thread #1 finished" ...
  2014/03/07 08:05:10 [error] 12621#0: *2818394 FastCGI sent in stderr: "PHP message: Thread #3 finished" ...
  2014/03/07 08:05:10 [error] 12621#0: *2818394 FastCGI sent in stderr: "PHP message: Thread #6 finished" ...
  2014/03/07 08:05:10 [error] 12621#0: *2818394 FastCGI sent in stderr: "PHP message: Thread #5 finished" ...
  2014/03/07 08:05:10 [error] 12621#0: *2818394 FastCGI sent in stderr: "PHP message: Thread #7 finished" ...
  2014/03/07 08:05:10 [error] 12621#0: *2818394 FastCGI sent in stderr: "PHP message: Thread #4 finished" ...
  2014/03/07 08:05:10 [error] 12621#0: *2818394 FastCGI sent in stderr: "PHP message: Thread #8 finished" ...
  </pre>
  
  <p>In fact, I don't use any echo in my threads, I need to aggregate some webservices (each webservice class = thread), wait for the slowest thread, and merge all results to one array that could be taken from outside, but I never worked with threads in PHP or other languages before. I would appreciate if you give me some example. Thank you.</p>
  
  <p>Software:<br/>
  Gentoo x86<br/>
  PHP 5.4.23 (nginx configured to use php-fpm)<br/>
  Nginx 1.4.4</p>
  
  <p>No apache. PHP built threadsafe, pthreads module is enabled.</p>