| Previous | Next
ThreadProvides Perl multithreading support. Distributed as a beta feature with Perl 5.005 and runs only on versions of Perl that were built with thread support. Has the following functions and methods.
$t = new Thread \&sub[, params] Constructor. Starts a new thread in the referenced subroutine,
$t = async {block};
Creates a new thread to execute the block that follows it. The block is treated as an anonymous subroutine (and therefore has a semicolon after the closing bracket). Returns a thread object.
cond_broadcast var Like
cond_signal var Takes the locked variable var and unblocks one thread that's
cond_wait var Takes the locked variable var, unlocks it, and blocks until another thread does a
eval {$t->join}
Wraps an
$t->join Waits for a thread to end. When it does, returns any exit values from the thread. Blocks until the thread has ended, unless the thread has already terminated.
Thread->list Returns list of thread objects for all running and finished, but not
Locks a variable or a subroutine. A lock on a variable is maintained until the lock goes out of scope. If the variable is already locked by another thread, the Note that locks on variables affect only other Locking a subroutine blocks any calls to the subroutine until the lock goes out of scope; no other thread can access the subroutine while the lock is in effect.
Thread->self Returns an object representing the thread that made the call.
$id = $t->tid Returns an object representing the |