<html><body>
<p><tt>Scott Gargash schrieb:<br>
><br>
> I've run into an interaction with threads and the XOTcl exit handler <br>
> that I don't understand.<br>
><br>
> I create a thread from within an object, and release that thread in <br>
> the object's destructor. If I destroy the object directly, <br>
> everything's fine, but if I destroy the object through "Object <br>
> setExitHandler", I get an error. Am I treading into undefined <br>
> behavior? Is there well-defined way to shut down multiple threads?<br>
><br>
the thread and exit code is a tricky and sensitive area, especially if <br>
it is supposed to work with tcl and the aolserver. below is the somewhat <br>
simplified code (btw., your example works on mac os x without a <br>
problem). In general. there is no need to destroy the objects by hand, <br>
since these are destroyed automatically and the appropriate destroy <br>
methods are executed. also, the destroy order is not completely trivial <br>
in order to be able to execute the destroy methods correctly. i would <br>
not do this by hand.<br>
<br>
isn't the default beavior sufficient?</tt><br>
<br>
<tt>Unfortunately, the default behavior is not sufficient. My example was simplified from my real problem. In the real problem, I have essentially a directed graph of objects that I serialize out upon destruction. Since the default behavior doesn't destroy objects in a defined order, when the root object goes to serialize out, some nodes that it needs to serialize may already be destroyed. This is undesireable.</tt><br>
<br>
<tt>So I inserted my own exitHandler and that works in a single thread, but when I have multiple threads, things get confused. </tt><br>
<br>
<tt>BTW, the failure was on WinXP. Given that the behavior is different on different platforms, it does seem like I've treaded into undefined behavior. Is there any way to wrangle it back into something defined?</tt><br>
<br>
<tt>        Scott</tt></body></html>