Subject Thread Safe?
Author Jason Wharton

I'd like to say a few general remarks to add about multi-threading.

If you are using a TDataModule (or any form or TComponent) as the owner of
your data access objects then if the TIB_Session is the first in the
creation order then what happens when the other data access objects are
created they look at the other components their owner owns and looks for a
TIB_Session component among them. If it finds one then that data access
component associates itself to that session rather than the default session.

This is why you won't see any code explicitly assigning the IB_Session
property if all the data access components are siblings to their IB_Session.
It all just happens automatically behind the scenes.

If you are strictly in code and there is no container as an owner then what
you should do is create your TIB_Session with NIL (or whatever) as the owner
and then the subsequent data access objects can have the TIB_Session
instance passed in as the owner. Do not pass in NIL as the owner for any of
the other data access components unless you explicitly assign the
TIB_Session property after instantiating it. You can also use the
CreateForSession() constructor that allows you to give it an owner and
declare which session the component goes with.

Hope this helps,
Jason L Wharton