Availability:built-in
thread_property(?Id,
?Property)True if thread Id has Property. Either or both
arguments may be unbound, enumerating all relations on backtracking.
Calling thread_property/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 opaque thread identifier. Defined properties are:
- alias(Alias)
- Alias is the alias name of thread Id.
- detached(Boolean)
- Current detached status of the thread.
- id(Integer)
- Integer identifier for the thread. Can be used as argument to the thread
predicates, but applications must be aware that these references are
reused.
- status(Status)
- Current status of the thread. 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.
- suspended
- Only if the thread is an engine (see section
11). Indicates that the engine is currently not associated with an
OS thread.
- 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).
- engine(Boolean)
- If the thread is an engine (see chapter
11), Boolean is
true
. Otherwise the property is not present.
- thread(ThreadId)
- If the thread is an engine that is currently attached to a thread,
ThreadId is the thread that executes the engine.
- size(Bytes)
- The amount of memory associated with this thread. This includes the
thread structure, its stacks, its default message queue, its clauses in
its thread local dynamic predicates (see thread_local/1)
and memory used for representing thread-local answer tries (see section
7).
- system_thread_id(Integer)
- Thread identifier used by the operating system for the calling thread.
Not available on all OSes. This is the same as the Prolog flag
system_thread_id
for the calling thread. Access to the system thread identifier can, on
some systems, be used to gain additional control over or information
about Prolog threads.
See also thread_statistics/3
to obtain resource usage information and
message_queue_property/2
to get the number of queued messages for a thread.