join() 공개 메소드

Causes the calling context to wait for the referenced Thread to finish executing
public join ( ) : boolean
리턴 boolean A boolean indication of state
예제 #1
0
 /**
  * @expectedException RuntimeException
  */
 public function testThreadAlreadyJoined()
 {
     $thread = new Thread();
     $this->assertEquals($thread->start(), true);
     $this->assertEquals($thread->join(), true);
     $this->assertEquals($thread->join(), false);
 }
예제 #2
0
 /**
  * @expectedException RuntimeException
  */
 public function testThreadAlreadyJoined()
 {
     $thread = new Thread();
     $this->assertTrue($thread->start());
     $this->assertTrue($thread->join());
     $this->assertFalse($thread->join());
 }
예제 #3
0
 public function handle(\Thread $thread)
 {
     $thread->start();
     echo "Start thread with ID {$thread->getCurrentThreadId()}\n";
     return Observable::create(function (ObserverInterface $observer) use($thread) {
         while ($thread->isRunning()) {
             $this->loop->tick();
         }
         try {
             echo "Thread finished\n";
             $thread->join();
             $observer->onNext(new Event('/thread/ok', $thread));
             $observer->onCompleted();
         } catch (\Exception $e) {
             echo "Thread error\n";
             $observer->onError($e);
         }
         unset($thread);
     });
 }