Рекурсивный акроним словосочетания «PHP: Hypertext Preprocessor»
Добро пожаловать на форум PHP программистов!
За последние 24 часа нас посетили 18475 программистов и 1688 роботов. Сейчас ищет 1131 программист ...
Method Modifiers
Вернуться к: pthreads
pthreads overrides the functionality of the protected and private method modifiers in order to provide functionality more suited to multi-threaded objects. pthreads applies this functionality to all Threaded objects from creation.
Пример #1 protected method example: protected methods can only be executed by one Thread at a time.
<?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();
}
?>
Пример #2 private method example: private methods may only be executed by the Threaded object during execution
<?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();
}
?>
Вернуться к: pthreads