Index: openacs-4/packages/xotcl-core/tcl/40-thread-mod-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/40-thread-mod-procs.tcl,v diff -u -N -r1.20.2.3 -r1.20.2.4 --- openacs-4/packages/xotcl-core/tcl/40-thread-mod-procs.tcl 8 May 2019 14:31:17 -0000 1.20.2.3 +++ openacs-4/packages/xotcl-core/tcl/40-thread-mod-procs.tcl 16 Sep 2021 09:51:55 -0000 1.20.2.4 @@ -206,7 +206,6 @@ } else { set tid [::thread::create] } - nsv_set [self class] [self] $tid if {[:persistent]} { :log "--created new persistent [self class] as $tid pid=[pid]" } else { @@ -225,6 +224,12 @@ append initcmd ${:initcmd} #ns_log notice "INIT $initcmd" ::thread::send $tid $initcmd + + # + # Tell the world about the thread only once it is fully + # working to avoid potential race-conditions during startup. + # + nsv_set [self class] [self] $tid } else { set tid [nsv_get [self class] [self]] }