By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,746 Members | 1,735 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,746 IT Pros & Developers. It's quick & easy.

PHP and Multi-thread

P: n/a
Hi All,

I can not find any information if PHP support multi-thread (Posix
thread) or not at all, can someone give out some information? Is it
supported? If yes, where's the info? If no, is it possible to make
doing multi-thread stuff?

Thanks.

YF
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
OutsiderJustice wrote:
I can not find any information if PHP support multi-thread (Posix
thread) or not at all, can someone give out some information? Is it
supported? If yes, where's the info? If no, is it possible to make
doing multi-thread stuff?


You can do it, but don't try doing it when it's a script on a webserver.
Check out the following links (the 1st one is the PHP manual; the 2nd one
is a link on my website about how to do just this):

http://www.php.net/pcntl
http://www.electrictoolbox.com/artic...ocess-forking/

Chris

--
Chris Hope
The Electric Toolbox Ltd
http://www.electrictoolbox.com/
Jul 17 '05 #2

P: n/a
Chris Hope <bl*******@electrictoolbox.com> wrote in message news:<7x******************@news.xtra.co.nz>...
OutsiderJustice wrote:
I can not find any information if PHP support multi-thread (Posix
thread) or not at all, can someone give out some information? Is it
supported? If yes, where's the info? If no, is it possible to make
doing multi-thread stuff?


You can do it, but don't try doing it when it's a script on a webserver.
Check out the following links (the 1st one is the PHP manual; the 2nd one
is a link on my website about how to do just this):

http://www.php.net/pcntl
http://www.electrictoolbox.com/artic...ocess-forking/

Chris


Unfortunately there are so many problems with it:

- it is not really multi-thread, it's multi-process, it's expensive to
duplicate all resources in the child process
- it is only available on UNIX system; even so, if one forgot to do
'--enable-pcntl' when compiling PHP, one has to compile it again,
which can be a hassle.

I'm not a Windows guy, but I believe Windows also has it's own process
control APIs, so I'm kind of wondering why this is not implemented on
Windows version.

Is there anything may be useful to achieve multi-thread performance on
Windows system?

Yufeng
Jul 17 '05 #3

P: n/a
OutsiderJustice wrote:
Unfortunately there are so many problems with it:

- it is not really multi-thread, it's multi-process, it's expensive to
duplicate all resources in the child process
- it is only available on UNIX system; even so, if one forgot to do
'--enable-pcntl' when compiling PHP, one has to compile it again,
which can be a hassle.

I'm not a Windows guy, but I believe Windows also has it's own process
control APIs, so I'm kind of wondering why this is not implemented on
Windows version.

Is there anything may be useful to achieve multi-thread performance on
Windows system?


Yeah you're right it's not multi-threading proper, which I have done in .NET
with both VB and C#. As far as I have been able to determine there is no
way to do this in PHP other than using process forking. If someone else is
able to help out here I'd be interested to, although I'm coming from a Unix
platform not a Windows one.

Chris

--
Chris Hope
The Electric Toolbox Ltd
http://www.electrictoolbox.com/
Jul 17 '05 #4

P: n/a
"OutsiderJustice" <ou*************@yahoo.com> wrote in message
news:61**************************@posting.google.c om...
Chris Hope <bl*******@electrictoolbox.com> wrote in message news:<7x******************@news.xtra.co.nz>... I'm not a Windows guy, but I believe Windows also has it's own process
control APIs, so I'm kind of wondering why this is not implemented on
Windows version.

Is there anything may be useful to achieve multi-thread performance on
Windows system?


Take a look at the Win32 extension. In theory you can build a wrapper around
the W32 API. In practice though, it will probably be very unstable--if it
works at all.
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.