mirror of
https://github.com/php/doc-es.git
synced 2026-03-26 08:22:08 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@334270 c90b9560-bf6c-de11-be94-00142212c4b1
88 lines
2.2 KiB
XML
88 lines
2.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 4fcca4ebb5f0ae702ea38d413ab35d2cef267eac Maintainer: seros Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
|
|
<chapter xml:id="pthreads.modifiers" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<title>Modificadores de métodos</title>
|
|
<titleabbrev>Modificadores</titleabbrev>
|
|
<para>
|
|
pthreads sobrescribe la funcionalidad de los modificadores de métodos protegidos y privados para proporcionar funcionalidad más adecuada para objetos multihilo.
|
|
pthreads aplica esta funcionalidad a todos los objetos Threaded desde su creación.
|
|
</para>
|
|
<example>
|
|
<title>Ejemplo de método protegido: los métodos protegidos solamente pueden ser ejecutados por un Thread a la vez.</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
class EjemploThread extends Thread {
|
|
public function run() {
|
|
/* código del Thread */
|
|
if ($this->synchronized()) {
|
|
|
|
}
|
|
}
|
|
|
|
protected function exclusive() {
|
|
/* método sincronizado */
|
|
}
|
|
}
|
|
|
|
$thread = new EjemploThread();
|
|
if ($thread->start()) {
|
|
$thread->exclusive();
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
<example>
|
|
<title>Ejemplo de método privado: los métodos privados solamente pueden ser ejecutados por el objeto Threaded durante su ejecución</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
class EjemploThread extends Thread {
|
|
public function run() {
|
|
/* código del Thread */
|
|
if ($this->insideonly()) {
|
|
|
|
}
|
|
}
|
|
|
|
private function insideonly() {
|
|
/* método privado */
|
|
}
|
|
}
|
|
|
|
$thread = new EjemploThread();
|
|
if ($thread->start()) {
|
|
$thread->insideonly();
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</chapter>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|
|
|