title: Prevent tcl thread from being blocked by main event loop
body: <p>I am trying to run a thread continuously and not have it become blocked by the tcl main event loop.
  Here is a simple example of what I'm trying to do: </p>
  
  <pre><code>#!/bin/sh
  #\
  exec tclsh "$0" "$@"
  
  package require Thread
  
  set ::a_thread [thread::create {thread::wait}]
  
  proc start_a {} {
    thread::send $::a_thread {
      puts "Running a thread"
    }
    after 1000 a_start
  }
  
  proc infinite_loop {} {
    while {1} {
      puts "Loop"
      after 500
    }
  }
  
  start_a
  infinite_loop
  
  vwait forever
  </code></pre>
  
  <p>In this code, the <code>infinite_loop</code> proc is called and the main event loop runs infinitely. I would like it if the <code>a_thread</code> could still run in the background though. How can I achieve this?</p>