Because threads were a relatively late addition to Emacs Lisp, and due to the way dynamic binding was sometimes used in conjunction with accept-process-output, by default a process is locked to the thread that created it. When a process is locked to a thread, output from the process can only be accepted by that thread.
A Lisp program can specify to which thread a process is to be locked, or instruct Emacs to unlock a process, in which case its output can be processed by any thread. Only a single thread will wait for output from a given process at one time—once one thread begins waiting for output, the process is temporarily locked until accept-process-output or sit-for returns.
If the thread exits, all the processes locked to it are unlocked.
Return the thread to which process is locked. If process is unlocked, return nil.
Set the locking thread of process to thread. thread may be nil, in which case the process is unlocked.
Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc.
Licensed under the GNU GPL license.
https://www.gnu.org/software/emacs/manual/html_node/elisp/Processes-and-Threads.html