Availability:built-in
thread_send_message(+QueueOrThreadId,
+Term)Place Term in the given queue or default queue of the
indicated thread (which can even be the message queue of itself, see
thread_self/1).
Any term can be placed in a message queue, but note that the term is
copied to the receiving thread and variable bindings are thus lost. This
call returns immediately.
If more than one thread is waiting for messages on the given queue
and at least one of these is waiting with a partially instantiated
Term, the waiting threads are all sent a wake-up
signal, starting a rush for the available messages in the queue. This
behaviour can seriously harm performance with many threads waiting on
the same queue as all-but-the-winner perform a useless scan of the
queue. If there is only one waiting thread or all waiting threads wait
with an unbound variable, an arbitrary thread is restarted to scan the
queue.201See the documentation for
the POSIX thread functions pthread_cond_signal() v.s. pthread_cond_broadcast()
for background information.