Can you have multiple threads in PHP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

ZeroFear
Forum Newbie
Posts: 14
Joined: Tue Feb 14, 2006 10:47 pm

Can you have multiple threads in PHP?

Post by ZeroFear »

Can you create multiple threads in php?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Nope.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Short threads. Nice.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

No Everah, in php you can't create even short threads :D
User avatar
sweatje
Forum Contributor
Posts: 277
Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA

Post by sweatje »

feyd wrote:Nope.
That was a little verbose. I think
No.
would have sufficed.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

sweatje wrote:That was a little verbose. I think
No.
would have sufficed.
Probably, but since I knew what the answer would be before opening the thread, I had to consider the breviloquence of such a message. Based on this conundrum, I chose the more grandiloquent, while still inherently specific and finite .. phrase.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

feyd wrote:
sweatje wrote:That was a little verbose. I think
No.
would have sufficed.
Probably, but since I knew what the answer would be before opening the thread, I had to consider the breviloquence of such a message. Based on this conundrum, I chose the more grandiloquent, while still inherently specific and finite .. phrase.
Things to do...
Look up breviloquence
Look up conundrum
Look up grandiloquent
Egg my English teachers house for not teaching me those words

@weirdan: I had no idea that came out the way it did... Short threads, Ha! I hadn't even paid attention to the fact that this thread was about threads and that replying with the word thread was inherently going to cause me to look like a caught unawares @$$.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Things to do...
Look up breviloquence
Look up conundrum
Look up grandiloquent
Egg my English teachers house for not teaching me those words
Heh, how does it feel to be in my shoes? :D

To understand 'breviloquence' I had first to lookup this term in the wikipedia and then use multitran.ru to translate the definition to Russian :). On the other hand, once you know what breviloquence is you could guess what 'grandiloquent' means :D
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Chapter 5 of Advanced PHP Programming, page 130, "Create and Managing Child Processes" explains this.
PHP Supports traditional Unix multitasking by allowing a process to spawn child processes via pcntl_fork()...
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

processes and threads are completely different things.
User avatar
sweatje
Forum Contributor
Posts: 277
Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA

Post by sweatje »

feyd wrote:
sweatje wrote:That was a little verbose. I think
No.
would have sufficed.
Probably, but since I knew what the answer would be before opening the thread, I had to consider the breviloquence of such a message. Based on this conundrum, I chose the more grandiloquent, while still inherently specific and finite .. phrase.
I appreciated your messages affability. It had an air of congeniality, without the aloof connotations of the more concise version. Even in your subsequent repartee, you had no need to resort to truly sesquipedalian vocabulary. You definitely have the penultimate vocabulary on PHPDN ;)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

!?!?!?!??!?!?!?

I feel so am stoopid.Image
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Weirdan wrote:To understand 'breviloquence' I had first to lookup this term in the wikipedia and then use multitran.ru to translate the definition to Russian :).
Wow... I hadn't noticed it says Ukraine in your location. Your (bulletin board) english is indistiguishable from the rest of the regular posters here.
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

Post by pedrotuga »

Everah wrote:Short threads. Nice.
Weirdan wrote:No Everah, in php you can't create even short threads
Everah wrote:!?!?!?!??!?!?!?

I feel so am stoopid.
looll.... R-O-T-F-F-L!
ehehehe this is one of the gratest piece of humor i heard lately
Rovas
Forum Contributor
Posts: 272
Joined: Mon Aug 21, 2006 7:09 am
Location: Romania

Post by Rovas »

In the OS Windows you can' t have multithreading for PHP in UNIX you can have using what astions said.
Some clarification on threads or process
A process is the "heaviest" unit of kernel scheduling. Processes own resources allocated by the operating system. Resources include memory, file handles, sockets, device handles, and windows. Processes do not share address spaces or file resources except through explicit methods such as inheriting file handles or shared memory segments, or mapping the same file in a shared way. Processes are typically pre-emptively multitasked. However, Windows 3.1 and older versions of Mac OS used co-operative or non-preemptive multitasking.

A thread is the "lightest" unit of kernel scheduling. At least one thread exists within each process. If multiple threads can exist within a process, then they share the same memory and file resources. Threads are pre-emptively multitasked if the operating system's process scheduler is pre-emptive. Threads do not own resources except for a stack and a copy of the registers including the program counter.
For more information on threads and process visit http://en.wikipedia.org/wiki/Multithreading
Post Reply