Hello,

is there a reason why interrupt-thread doesn't seem to run the requested function in some cases? The following code tries to run a function in each existing thread (the variable *output* logs the calls that we try to run and the ones that are actually run).

(defvar *output*)

(defun test-run ()
  (setf *output* nil)
  (threads:mapcar-threads
   (lambda (thread)
     (push (format nil "~A : calling" thread) *output*)
     (threads:interrupt-thread thread
      (lambda () 
(push (format nil "~A : running" thread) *output*))))))

(defun test-report ()
  (format t "~{~A~%~}" (reverse *output*)))

Running in the command line:

CL-USER(5): (threads:make-thread #'test-run :name "TEST-RUN")
#<THREAD "TEST-RUN" {49BBE826}>

CL-USER(6): (test-report)
#<THREAD "TEST-RUN" {49BBE826}> : calling
#<THREAD "interpreter" {409CB8AF}> : calling

I can understand that the thread "TEST-RUN" that I create to run the function might disappear before it gets to run the function as requested, or maybe the reason is that a thread can't interrupt itself by design... But why doesn't the thread "interpreter" run the function?

Running in slime there are many threads present, and most of them will respond as expected. But "TEST-RUN", "interpreter" and "reader-thread" won't.
 
#<THREAD "control-thread" {3C036436}> : calling
#<THREAD "reader-thread" {10A08BAA}> : calling
#<THREAD "swank-indentation-cache-thread" {2A83402}> : calling
#<THREAD "Swank Sentinel" {66E71110}> : calling
#<THREAD "repl-thread" {699D8335}> : calling
#<THREAD "Swank Sentinel" {66E71110}> : running
#<THREAD "TEST-RUN" {4E0267BA}> : calling
#<THREAD "repl-thread" {699D8335}> : running
#<THREAD "auto-flush-thread" {6913E490}> : calling
#<THREAD "interpreter" {1902DFD5}> : calling
#<THREAD "auto-flush-thread" {6913E490}> : running
#<THREAD "swank-indentation-cache-thread" {2A83402}> : running
#<THREAD "control-thread" {3C036436}> : running

Cheers,

Carlos