PHP code example of bettergist / concurrency-helper

1. Go to this page and download the library: Download bettergist/concurrency-helper 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/ */

    

bettergist / concurrency-helper example snippets


    $myParallelizedFunction = function (int $childNumber, array $packages, $optionalExtraParameter) {
    echo "Thread $childNumber: " . implode(', ', $packages) . " of $optionalExtraParameter\n";
    
        sleep($childNumber * 1);
    
        echo "Finished Thread $childNumber.\n";
    };
    
    $states = [
    'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado',
    'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho',
    ];
    
    $runner = new BettergistCollective\ConcurrencyHelper\ConcurrencyHelper();
    $runner->concurrentlyRun($states, 6, $myParallelizedFunction, [count($states)]);