here is a simple example of what I am not understanding :
<?php
class classA {
private $z = 1;
public function __construct() {
$this->b = new classB;
$this->b->setRefonClassA($this);
$this->b->start();
}
function changeZ() {
echo "ChangeZ : z=" . $this->z . "\n";
$this->z = 666;
echo "ChangeZ : z=" . $this->z . "\n";
}
function showZ() {
echo "showZ : z=" . $this->z . "\n";
}
}
class classB extends Thread {
function setRefOnClassA($classA) {
$this->classA = $classA;
}
function run() {
$this->classA->changeZ();
$this->classA->showZ();
}
}
$test = new classA(); ?>
The result are :
ChangeZ : z=1
ChangeZ : z=666
showZ : z=1
I was expecting that showZ=666. Why z=1 ?
I'm clearly missing something here.
Thanks in advance