title: Share array between pthreads
body: <p>I have the following PHP code:</p>
  
  <pre><code>&lt;?php
  
  class StackableAr extends Stackable{
      public function run(){}
  }
  
  class MyThread1 extends Thread{
  
      public $settings;
  
      public function __construct($settings){
          $this-&gt;settings = $settings;
      }
  
      public function run(){
          print "thread1: start\n";
          for($n = 0; $n &lt; 8; $n++){
              print "thread1: $n\n";
              if($n == 2){
                  print_r($this-&gt;settings);
              }
              elseif($n == 4){
                  $this-&gt;settings['test2'] = new StackableAr();
                  $this-&gt;settings['test2']['attr2'] = 'string2';
                  $this-&gt;settings['test3'] = 'string3';
              }
              elseif($n == 6){
                  print_r($this-&gt;settings);
              }
              sleep(1);
          }
          print "thread1: end\n";
      }
  }
  
  class MyThread2 extends Thread{
  
      public $settings;
  
      public function __construct($settings){
          $this-&gt;settings = $settings;
      }
  
      public function run(){
          print "thread2: start\n";
          for($n = 0; $n &lt; 10; $n++){
              print "thread2: $n\n";
              if($n == 8){
                  print_r($this-&gt;settings);
              }
              sleep(1);
          }
          print "thread2: end\n";
      }
  }
  
  $settings = new StackableAr();
  $settings['test1'] = new StackableAr();
  $settings['test1']['attr1'] = 'string1';
  
  $myThread1 = new MyThread1($settings);
  $myThread2 = new MyThread2($settings);
  
  $myThread1-&gt;start();
  $myThread2-&gt;start();
  
  for($n = 0; $n &lt; 12; $n++){
      print "main: $n\n";
      sleep(1);
  }
  ?&gt;
  </code></pre>
  
  <p>How can I make <code>$this-&gt;settings['test2']</code> persist even if thread1 doesn't exist anymore. I made it like <a href="https://github.com/krakjoe/pthreads/blob/22855cbdb6e868d700b5d18d1df356b8b83cb09a/examples/StackableArray.php" rel="nofollow">pthread PHP example note</a> says: <em>You can and should use a Stackable as a base object for all arrays you wish to pass to other threads</em><br>
  <code>$this-&gt;settings['test3']</code> persists after thread1 ended. But why not <code>$this-&gt;settings['test2']</code>?</p>