public function run() { echo 'Hello, I am a thread with id ' . $this->getPid() . "!\nTrying to lock the critical section\n"; $lock = new GPhpThreadLockGuard($this->criticalSection); echo "=--- locked " . $this->getPid() . "\n"; $this->criticalSection->addOrUpdateResource('IAM', $this->getPid()); $criticalSection2 = new GPhpThreadCriticalSection(); $a = new MyThreadThread($criticalSection2, true); $b = new MyThreadThread($criticalSection2, true); $a->start(); $b->start(); $a->join(); $b->join(); $criticalSection2->lock(); echo "=###= Last internal cs value: " . $criticalSection2->getResourceValue('IAM') . "\n"; $criticalSection2->unlock(); $this->criticalSection->addOrUpdateResource('IAMNOT', '0xdead1'); $this->criticalSection->removeResource('IAMNOT'); echo "=--- unlocked " . $this->getPid() . "\n"; GPhpThread::resetThreadIdGenerator(); $ms2 = new MyStuff('heavy thread 1'); }