Object-oriented thread API
Makes the most important multi-threading primitives available using object types. For single-threaded apps, the operations are substituted by no-ops.
Whether this is a single-threaded program. In this case, a number of methods change their meaning, as described below.
In a multi-threaded program: Starts a new thread, and calls the
passed function with the passed argument in the new thread
(like Thread.create
).
In a single-threaded program: fails.
In a multi-threaded program: Returns the currently running thread.
Subsequent calls of self
can return different objects for the
same thread, but the id
method will always return the same number.
In a single-threaded program: Returns a dummy object (see below).
In a multi-threaded program: gives a hint that another thread should better run now. In a single-threaded program: this is a no-op.
In a multi-threaded program: Returns the thread ID. In a single-threaded program: Returns 0.
In a multi-threaded program: Suspends the calling thread until this thread terminates. In a single-threaded program: fails
May be used internally be the implementation
In a multi-threaded program: Suspends the calling thread until the mutex is locked. In a single-threaded program: This is a no-op
In a multi-threaded program: Unlocks a mutex. In a single-threaded program: This is a no-op
In a multi-threaded program: Tries to immediately lock the mutex,
and returns whether the lock could be obtained.
In a single-threaded program: returns true
May be used internally be the implementation
In a multi-threaded program: Wait for the condition to be true and use the mutex to protect this situation. In a single-threaded program: this is a no-op.
In a multi-threaded program: Signal one process that the condition holds. In a single-threaded program: this is a no-op.
In a multi-threaded program: Signal all waiting processes that the condition holds. In a single-threaded program: this is a no-op.
May be used internally be the implementation