PHP code example of alicemajere / wonderland-thread
1. Go to this page and download the library: Download alicemajere/wonderland-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/ */
alicemajere / wonderland-thread example snippets
php
$threadPool = new ThreadPool();
php
$threadPool->setMaxRunningThreadNb(5);
php
$thread = ThreadFactory::create(
'ThreadName',
function ($processName) {
// Implements the Thread processing here
echo $processName . PHP_EOL;
// return an exit status at the end of the thread
return Thread::EXIT_STATUS_SUCCESS;
}
)
$threadPool->addThread($thread);
$threadPool->run();
php
$threadPool->addListener(new Listener(
Event::POOL_RUN_START, // Event to trigger the listener
function (Event $event) use ($website) {
// Implements the listener
})
);
$threadPool->addListener(new Listener(
Event::POOL_RUN_STOP,
function (Event $event) {
$this->io->progressFinish();
})
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.