Support for threads needs to be built into the Perl executable.
threads implements thread objects and the necessary operations for threads. Some of the most relevant operations are:
Starts a thread to execute the block. Returns the thread object.
Creates a new thread that starts executing in the referenced subroutine. The args are passed to this subroutine. Returns the thread object.
Returns a list of joinable threads.
Returns an object representing the current thread.
Returns the thread ID of the current thread.
The current thread gives up the CPU in favor of other threads.
thread objects support the several methods, including:
Detaches a thread so it runs independently.
Returns true if the thread and thread are the same thread. You can also compare thread objects directly, using the
Waits for the thread to complete. The value returned is the return value from the thread’s subroutine.
Returns the thread ID of a thread.
threads::shared implements operations that enable variable sharing across threads:
Unblocks all threads waiting for this variable. variable must be locked.
Unblocks one thread that is waiting for this variable. variable must be locked.
,] variable, time
Like cond_wait, but times out at the indicated time.
Waits for another ...