Location: PHPKode > scripts > Threading > threading/example.php
<?
	include "application.php";
	if( $Application->child !== false )
	{
		// Child
		print 'Start at ' . date("H:i:s") . chr(10);
		print 'I\'m child #' . $Application->child . chr(10);
		sleep(rand(0,10));
		$Application->XYU = $Application->XYU + 1;
		print 'Stop at ' . date("H:i:s") . chr(10);
	}
	else
	{
		// Parent
		$Application->XYU = 0;
		
		print 'I\'m parent. ' . $Application->child . chr(10);
		$Application->startThreads(10);
		
		$cur_c = 0;
		$las_c = 10;
		
		while( ($cur_c = $Application->childs()) > 0)
		{
			if($cur_c != $las_c)
			{
				print 'There are ' . $cur_c . ' childs on fly.' . chr(10);
				print 'XYU: ' . $Application->XYU . chr(10).chr(10);
			}
			$las_c = $cur_c;
			sleep(1);
		}
	}
	print 'XYU: ' . $Application->XYU . chr(10).chr(10);
?>
Return current item: Threading