Built-in Module thread

thread

This module provides low-level primitives for working with multiple threads (a.k.a. light-weight processes or tasks) — multiple threads of control sharing their global data space. For synchronization, simple locks (a.k.a. mutexes or binary semaphores) are provided.

The module is optional and supported on SGI and Sun Sparc systems only.

It defines the following constant and functions:


\begin{excdesc}{error}
Raised on thread-specific errors.
\end{excdesc}


\begin{funcdesc}{start_new_thread}{func\, arg}
Start a new thread. The thread ex...
...ed and
then the thread exits (but other threads continue to run).
\end{funcdesc}


\begin{funcdesc}{exit_thread}{}
Exit the current thread silently. Other threads ...
...{Caveat:} code in pending \code{finally} clauses is not executed.
\end{funcdesc}


\begin{funcdesc}{exit_prog}{status}
Exit all threads and report the value of the...
...ly} clauses, in this thread
or in other threads, is not executed.
\end{funcdesc}


\begin{funcdesc}{allocate_lock}{}
Return a new lock object. Methods of locks are described below. The
lock is initially unlocked.
\end{funcdesc}

Lock objects have the following methods:


\begin{funcdesc}{acquire}{waitflag}
Without the optional argument, this method a...
...return value is 1 if the lock is acquired successfully, 0 if not.
\end{funcdesc}


\begin{funcdesc}{release}{}
Releases the lock. The lock must have been acquired earlier, but not
necessarily by the same thread.
\end{funcdesc}


\begin{funcdesc}{locked}{}
Return the status of the lock: 1 if it has been acquired by some
thread, 0 if not.
\end{funcdesc}

Caveats: