Posted to tcl by Poor Yorick at Wed Nov 10 12:39:26 GMT 2021view raw

  1. package require Thread
  2.  
  3. proc handle_result args {
  4. puts [list {variable is changed} $args]
  5. }
  6.  
  7. proc threaderror {tid msg} {
  8. puts [list {thread error} $tid $msg]
  9. }
  10.  
  11. proc main thread {
  12. thread::send -async $thread {
  13. proc bg args {
  14. puts oogah!
  15. puts stderr [list glub! $args]
  16. flush stderr
  17. }
  18. interp bgerror {} bg
  19. puts zoink
  20. }
  21. thread::send -async $thread {error {an error}} a
  22. }
  23.  
  24.  
  25. thread::errorproc threaderror
  26. interp create t1
  27. set thread [thread::create]
  28.  
  29. after 0 [list [namespace which main] $thread]
  30.  
  31. vwait forever
  32.