semaphore = $this->createSemaphore(1); $thread1 = new Thread(function (SyncSemaphore $semaphore) { $lock = yield from $semaphore->acquire(); usleep(1e5); $lock->release(); return 0; }, $this->semaphore); $thread2 = new Thread(function (SyncSemaphore $semaphore) { $lock = yield from $semaphore->acquire(); usleep(1e5); $lock->release(); return 1; }, $this->semaphore); $start = microtime(true); $thread1->start(); $thread2->start(); yield from $thread1->join(); yield from $thread2->join(); $this->assertGreaterThan(1, microtime(true) - $start); }); Loop\run(); } }