Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
PHP does not have threading anywhere in its massive core. We can, however, fake it by relying on the underlying operating system’s multitasking abilities instead of PHP. This article will show you how.
PHP has no built in support for threading. But there can still be times when you’ve got lengthy code to run and idle CPU cyles you’d like to capitalize on. We can treat child processes as threads.
This isn’t true multithreading. We’re just running multiple processes, and facilitating communication between them. As each thread is a separate instance or part of your application, its entry point needs to re-include all code you’d normally need: functions and classes established at the time you create a thread are not automatically visable to the new thread. Performance isn’t great, as PHP has to re-parse every file multiple times.
А так, еще один интересный факт. Carbon фреймворк на Mac OS X использует свой трид менеджер, который реализует cooperative модель, когда сама Mac OS X использует preemptive.
Обзор моделей работы с потоками