<html><body>
<p>I've run into an interaction with threads and the XOTcl exit handler that I don't understand. <br>
<br>
I create a thread from within an object, and release that thread in the object's destructor. If I destroy the object directly, everything's fine, but if I destroy the object through "Object setExitHandler", I get an error. Am I treading into undefined behavior? Is there well-defined way to shut down multiple threads?<br>
<br>
        Scott<br>
<br>
Here's some sample code:<br>
<br>
package require XOTcl<br>
package require Thread<br>
<br>
namespace import {xotcl::*}<br>
Class A<br>
A instproc init {} {<br>
my set tid [thread::create [subst -nocommands {<br>
set ::auto_path [list $::auto_path]<br>
package require XOTcl<br>
namespace import {xotcl::*}<br>
Object b<br>
thread::wait<br>
}]]<br>
}<br>
<br>
A instproc destroy {args} {<br>
thread::send [my set tid] {b destroy}<br>
thread::release [my set tid]<br>
next<br>
}<br>
<br>
A a<br>
if {0} {<br>
# This gives an error<br>
xotcl::Object setExitHandler {a destroy}<br>
} else {<br>
# this works<br>
a destroy<br>
}<br>
<br>
exit<br>
<br>
</body></html>