title: How should a PHP thread store its data?
body: <p>So I have been googling and reading up and down the internet about PHP pthreads3 and how they are supposed to store data. (Or rather, how they are not)
  It seems to me that the only way for a thread to store its data properly is to create a new Threaded object and send it to the thread. The thread can then use this Threaded object to store nearly any data.</p>
  
  <p>My question, and biggest issue with grasping PHP threads:
  Is it possible to have the thread create its own storage objects when it wants?
  I have no idea how or why, since all the answer I've found on this tell a vague, elaborate and confusing "maybe, but no", mostly related to poor performance and memory issues/safety.
  This seems like it should be possible, somehow:</p>
  
  <pre><code>class someFantasticThread extends Thread {
      public $someData;
  
      function run(){
          while(true){
              //Create a fresh storage for the new data this iteration
              $this-&gt;someData = new SomeCoolStorage(); // Can this work somehow without all the issues?
              $this-&gt;someData[] = 'amazingdata'; // Do something amazing and store the new results in $someData
              $this-&gt;someData[] = new SomeCoolStorage(); // This would also be desireable, if it can somehow be done
              //don't mind the obvious loop issues. Imagine this is a well formed loop
          }
      }
  }
  
  class SomeCoolStorage extends Threaded{}
  
  // Start the thread
  $threadObj = new someFantasticThread();
  $threadObj-&gt;start();
  while(true){
      // at some point, retrieve the data and do something useful with the contained results
      // doSomethingAwesome($threadObj-&gt;someData);
  }
  </code></pre>