Normal multi-threaded applications should not need these the
predicates from this section because almost any usage of these
predicates is unsafe. For example checking the existence of a thread
before signalling it is of no use as it may vanish between the two
calls. Catching exceptions using catch/3
is the only safe way to deal with thread-existence errors.
These predicates are provided for diagnosis and monitoring tasks. See
also section 8.5, describing more high-level
primitives.
- current_thread(?Id,
?Status)
-
Enumerates identifiers and status of all currently known threads.
Calling current_thread/2
does not influence any thread. See also
thread_join/2.
For threads that have an alias-name, this name is returned in Id
instead of the numerical thread identifier.
Status is one of:
- running
-
The thread is running. This is the initial status of a thread. Please
note that threads waiting for something are considered running too.
- false
-
The Goal of the thread has been completed and failed.
- true
-
The Goal of the thread has been completed and succeeded.
- exited(Term)
-
The Goal of the thread has been terminated using thread_exit/1
with Term as argument. If the underlying native thread has
exited (using pthread_exit()) Term is unbound.
- exception(Term)
-
The Goal of the thread has been terminated due to an uncaught
exception (see throw/1
and catch/3).
- thread_statistics(+Id,
+Key, -Value)
-
Obtains statistical information on thread Id as statistics/2
does in single-threaded applications. This call returns all keys of statistics/2,
although only information statistics about the stacks and CPU time yield
different values for each thread. (67)
- mutex_statistics
-
Print usage statistics on internal mutexes and mutexes associated with
dynamic predicates. For each mutex two numbers are printed: the number
of times the mutex was acquired and the number of
collisions: the number times the calling thread has to wait for
the mutex. The collistion-count is not available on Windows as this
would break portability to Windows-95/98/ME or significantly harm
performance. Generally collision count is close to zero on single-CPU
hardware.