[Lazarus] Threads

Michael Schnell mschnell at lumino.de
Thu Mar 22 17:10:52 CET 2012


Besides what the other said a very basic comment.

The location where an object is defined (i.e. within a TThread enabled 
unit) or who created it (the main line code or the thread code) does not 
matter. The Concept of classes, objects and instances is a matter of 
memory allocation and pointers and not a concept of program flow. same 
is absolutely independent. You can use one instance of a class in one 
thread and another one in another thread. You can create an instance in 
one thread and call its procedures and properties by another one. (BTW 
this results in the fact that its very hard to define something like 
"Thread-safe" for a class).

In fact you need to look exactly how the program flow of each thread is 
before deciding what code needs to be protected regarding mutual 
accesses by threads. Just looking at the objects does not help much, 
Looking at the point where an object is created does not help at all.

-Michael




More information about the Lazarus mailing list