multithreading - when you terminate() a Thread (class TThread), does it exit every child of this thread? -
i have code in delphi following:
procedure thilo.execute; // (which thread) begin inherited; freeonterminate := true; while not terminated begin (...) sleep(100); end; end;
and somewhere else, in thread (or gui) this:
var hilo2: thilo; begin hilo2 := thilo.create(true); hilo2.start; hilo2 := thilo.create(true); hilo2.start; end;
now have executed 2 times same thread, , running in parallel. happens if this?:
hilo2.terminate;
will terminate both threads or 1, or what? also, if terminate it, achieve .resume()?
thanks in advance
when create second thread overwriting local variable hilo2
pointer second object - first object's pointer lost , no longer have reference (or way control it). result in memory leak if thread not terminate and, no, calling terminate not stop both threads, 1 last created variable reference. also, there no need call inherited
in execute
method of tthread - there nothing inherit (tthread's execute method abstract, doesn't anything).
Comments
Post a Comment