<?

require_once( 'Thread.php' );

// test to see if threading is available
if( ! Thread::available() ) {
    die( 'Threads not supported' );
}

$threads = array();
$index = 0;


function doBackup($klant)
{
    echo 'Check if backup exists';
}



while ($item = mysql_fetch_assoc($result)) {
    $threads[] = new Thread( 'doBackup' );
    $threads[]->start( $item );
}


// wait for all the threads to finish
while( !empty( $threads ) ) {
    foreach( $threads as $index => $thread ) {
        if( ! $thread->isAlive() ) {
            unset( $threads[$index] );
        }
    }
    // let the CPU do its work
    sleep( 1 );
}


?>