First working draft of thread-local binding.
At least 2 of the 9 kinds of variable bindings should work ok --
defvaralias variables and ordinary variables.
All other kinds will exhibit weird behavior.
A simple program that works:
(defvar zz t)
(defvar buffer-a (get-buffer-create "zardoz"))
(defun tha ()
(dolist (v '("A" "B" "C" "D"))
(message "thread a: %s" v)
(yield))
(setq zz nil))
(defun thb ()
(dolist (v '("E" "F" "G" "H" "I"))
(message "thread b: %s" v)
(yield)
))
(with-current-buffer buffer-a
(run-in-thread 'tha))
(thb)
(while zz
(yield))