On 06/10/2011 02:18 PM, Mattias Gaertner wrote:
E.g. Regarding Objects this is not enough.
Prove?

Theory: with multiple instances, the same "piece of code" behaves differently, according to to the states that are stored internally in an instance.

It's not practical to just ignore this as a specification: you now would need to say that Objects never are thread safe and by this make any object language totally unsuited for threaded application.

It's a lot more helpful to do a more sophisticated definition of thread-safety for objects.


Example:

Imagine you create an instance of an object for each thread.

So the same "piece of code" (a function procedure or property of the object) can behave differently regarding which instance is used (here which thread is calling it).

e.g. the function accesses just class variables (and local variables). Now it is thread safe if in fact each thread uses it's instance; but it's not thread safe, if a thread uses another thread's instance.

If it uses global variables it is not thread safe at all.

-Michael

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to