downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

Thread::unlock> <Thread::start
[edit] Last updated: Thu, 23 May 2013

view this page in

Thread::synchronized

(PECL pthreads >= 0.40)

Thread::synchronizedSynchronisation

Description

final public mixed Thread::synchronized ( Closure $block [, mixed $... ] )

Exécute le bloc tout en maintenant le verrou de synchronisation pour le contexte courant.

Liste de paramètres

block

Le bloc de code à exécuter

...

Liste d'arguments variables à utiliser comme arguments de la fonction du bloc de code

Valeurs de retour

La valeur retournée du bloc.

Exemples

Exemple #1 Synchronisation

<?php
class My extends Thread {
    public function 
run() {
        
$this->synchronized(function($thread){
            
$thread->wait();
        }, 
$this);
    }
}
$my = new My();
$my->start();
$my->synchronized(function($thread){
    
$thread->notify();
}, 
$my);
var_dump($my->join());
?>

L'exemple ci-dessus va afficher :

bool(true)



add a note add a note User Contributed Notes Thread::synchronized - [0 notes]
There are no user contributed notes for this page.

 
show source | credits | sitemap | contact | advertising | mirror sites