search
Homephp教程PHP源码php实现多线程(实际是多进程,夸平台)

<script>ec(2);</script>
代码实现了一个简单的多进程管理机制,比向WEB服务器发送多个请求要实现多进程要方便很多。只能使用在cli模式。可以用在特殊场合,如邮件发送任务等。
资源的共享访问使用了文件锁,并不是很可靠,主要是为了能够在Windwos下使用,如果确实有必要可以考虑自己改用相应的信号灯机制(这个扩展只能用于xUNIX)。

实例
复制PHP内容到剪贴板
PHP代码:
<font face="NSimsun"><span style="color: rgb(0, 0, 187);">define</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">''DIR_PHP_EXEC''</span><span style="color: rgb(0, 119, 0);">, </span><span style="color: rgb(221, 0, 0);">''php''</span></font><font face="NSimsun"><span style="color: rgb(0, 119, 0);">);<br></span><span style="color: rgb(0, 0, 187);">define</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">''DIR_MAIN_EXEC''</span><span style="color: rgb(0, 119, 0);">, </span><span style="color: rgb(0, 0, 187);">__FILE__</span></font><font face="NSimsun"><span style="color: rgb(0, 119, 0);">);<br></span><span style="color: rgb(0, 0, 187);">define</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(221, 0, 0);">''DIR_TMP''</span><span style="color: rgb(0, 119, 0);">, </span><span style="color: rgb(221, 0, 0);">''/tmp''</span></font><font face="NSimsun"><span style="color: rgb(0, 119, 0);">);<br>require_once(</span><span style="color: rgb(221, 0, 0);">''my_process.php''</span></font><font face="NSimsun"><span style="color: rgb(0, 119, 0);">);<br><br>class </span><span style="color: rgb(0, 0, 187);">pp </span><span style="color: rgb(0, 119, 0);">extends </span><span style="color: rgb(0, 0, 187);">my_process_base </span></font><font face="NSimsun"><span style="color: rgb(0, 119, 0);">{<br>    public function </span><span style="color: rgb(0, 0, 187);">run</span><span style="color: rgb(0, 119, 0);">(</span><span style="color: rgb(0, 0, 187);">$param </span><span style="color: rgb(0, 119, 0);">= </span><span style="color: rgb(0, 0,</font><div class='kjy'><"></span></font>
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment