PHP code example of jinraynor1 / threading

1. Go to this page and download the library: Download jinraynor1/threading library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jinraynor1 / threading example snippets


$queue = new ThreadQueue(function ($number) {
            return pow($number, 2);

});

$queue->enableMessaging(true);


$queue->add(1);
$queue->add(3);


$queue->wait();
$results = $queue->results();
$sum = array_sum($results);

// $sums now holds 9