I would implement threads in the following form

$thread_counter = 0;
$global = "lock";

$thread = new thread( \&thread_sub );
$thread->start();

thread_sub {
        lock( $global ) {
                print "i'm thread ", ++$thread_counter, "\n";
        }
}

It's a mixture of ithreads and the C# threading model. The thread works in
the same interpreter. You have to do locking by yourself. That would make
it light weighted and gives you the power to do everything you want. I
don't think that normal threads are very difficult to understand. But it
gives the highest flexibility.


Reply via email to