锟斤拷锟斤拷锟斤拷锟轿凤拷

Warning

锟斤拷锟斤拷锟斤拷锟斤拷 pthreads v2锟斤拷锟斤拷 pthreads v3 锟斤拷锟窖撅拷锟斤拷锟狡筹拷锟斤拷

pthreads 锟斤拷锟斤拷锟叫达拷锟斤拷锟轿� protected 锟斤拷 private 锟侥凤拷锟斤拷锟斤拷锟结供锟斤拷锟斤拷锟绞合讹拷锟竭程伙拷锟斤拷锟侥讹拷锟斤拷 锟斤拷锟斤拷锟斤拷锟叫碉拷 Threaded 锟斤拷锟斤拷pthreads 锟斤拷锟斤拷锟斤拷懈锟叫达拷锟斤拷锟斤拷锟�

Example #1 protected 锟斤拷锟斤拷示锟斤拷锟斤拷 锟斤拷锟轿� protected 锟侥凤拷锟斤拷锟斤拷同一时锟斤拷锟斤拷锟斤拷锟揭伙拷锟斤拷叱谭锟斤拷锟�

<?php
class ExampleThread extends Thread {
    public function 
run() {
        
/* thread code */
        
if ($this->synchronized()) {

        }
    }

    protected function 
exclusive() {
        
/* synchronized method */
    
}
}

$thread = new ExampleThread();
if (
$thread->start()) {
    
$thread->exclusive();
}
?>

Example #2 private 锟斤拷锟斤拷示锟斤拷锟斤拷锟斤拷锟轿� private 锟侥凤拷锟斤拷只锟斤拷锟缴达拷锟斤拷锟矫讹拷锟斤拷锟斤拷叱痰锟斤拷锟�

<?php
class ExampleThread extends Thread {
    public function 
run() {
        
/* thread code */
        
if ($this->insideonly()) {

        }
    }

    private function 
insideonly() {
        
/* private method */
    
}
}

$thread = new ExampleThread();
if (
$thread->start()) {
    
$thread->insideonly();
}
?>