GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   PHP Guru - Thread question (https://gfy.com/showthread.php?t=529764)

qw12er 10-19-2005 05:56 AM

PHP Guru - Thread question
 
Is there a way to do threads in PHP.

I tried pcntl_fork but it seems to works only on Unix server. (I'm Currently on Linux)

Thanks

ServerGenius 10-19-2005 06:11 AM

it does work on linux....but not with php as an apache module....you have to run
it as cgi.

PHP Code:


    <?php
    
include (?threadClass.php?);

    class 
testThread extends Thread {

      function 
testThread($name) {
        
$this->Thread($name); // calls the parent constructor and assign its name
      
}

      function 
run() {
        while(
true) {
          
sleep(1);
          print 
time() .?-? . $this->getName() . ? said ok?\n?; // every second we?re going to print this line?
        
}
      }
    }
    
// Main program. Bring up two instances of the same class (testThread).
    // They runs concurrently. It?s a multi-thread app with a few lines of code!!!

    
$test1 = new testThread (?Thread-1hahaha8243;);
    
$test2 = new testThread (?Thread-2hahaha8243;);
    
$test1->start();
    
$test2->start();

    print ?
This is the main processPress [CTRL-CANCto terminate.\n?;
    while(
true) {sleep(1);}

    
?>



All times are GMT -7. The time now is 05:24 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123