1. Go to this page and download the library: Download milanowicz/php-thread 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/ */
$worker = new Milanowicz\Thread\Worker([
'command' => '/bin/sleep 2',
'execMaxCounter' => 10, // How many would you execute?
'maxWorkers' => 2, // How process(es) should be started?
'maxExecutionTime' => 120, // Seconds to run php script
'memoryLimit' => '32M', // Maximum for php memory limit
'workerDelayStart' => 1, // Delay for starting processes after each other
'workerRunSleep' => 2, // Sleep to check again if enough processes are running
]);
$worker->setCheckDispatcher(function () { return <bool>; });
$worker->run(); // Main call to start worker loop
$worker->getThread(); // Get current Thread instance
$worker = new Milanowicz\Thread\Worker([
'command' => '/bin/sleep 20',
'execMaxCounter' => 10, // How many would you execute?
'maxWorkers' => 2, // How process(es) should be started?
], new Milanowicz\Thread\ThreadSingleton());
$worker->run();
shell
> composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.