inf
or
infinite
, which is mapped to the maximum stack size
supported by the platform.
false
(default), the thread can be waited for using
thread_join/2. thread_join/2
must be called on this thread to reclaim the all resources associated to
the thread. If true
, the system will reclaim all associated
resources automatically after the thread finishes. Please note that
thread identifiers are freed for reuse after a detached thread finishes
or a normal thread has been joined. See also thread_join/2
and thread_detach/1.
If a detached thread dies due to failure or exception of the initial goal the thread prints a message using print_message/2. If such termination is considered normal the code must be wrapped using ignore/1 and/or catch/3 to ensure successful completion.
The Goal argument is copied to the new Prolog engine. This implies further instantiation of this term in either thread does not have consequences for the other thread: Prolog threads do not share data from their stacks.
detached(true)
cannot be joined. See also thread_property/2.
A thread that has been completed without thread_join/2 being called on it is partly reclaimed: the Prolog stacks are released and the C-thread is destroyed. A small data-structure representing the exit-status of the thread is retained until thread_join/2 is called on the thread. Defined values for Status are:
detached(Bool)
option at
thread_create/3)
at runtime. Id is the identifier of the thread placed in
detached state. This may be the result of PL_thread_self/1.
One of the possible applications is to simplify debugging. Threads that are created as detached leave no traces if they crash. For not-detached threads the status can be inspected using thread_property/2. Threads nobody is waiting for may be created normally and detach themselves just before completion. This way they leave no traces on normal completion and their reason for failure can be inspected.
exited(Term)
as
result-state for thread_join/2.
If the thread has the attribute
detached(true)
it terminates, but its exit status cannot be
retrieved using thread_join/2
making the value of Term irrelevant. The Prolog stacks and
C-thread are reclaimed.
The current implementation does not guarantee proper releasing of all mutexes and proper cleanup in call_cleanup/2, etc. Please use the exception mechanism (throw/1) to abort execution using non-standard control.
at_exit(Goal)
argmument
of
thread_create/3.