Multithreaded application and TOracleSession.ThreadSafe

cdev

Member²
Hello

I have a multithreaded application where each thread owns its own session.
If I set the Threadsafe property to true for each sessions, does it mean there is a risk for all threads to block each other when they are accessing the database?
Does each thread stop waiting for query executing or is there a way to ask only to threads trying to use the session to be suspended during the use of this session?

Last question : what if Threadsafe = false and 2 threads ask for executing a select query?

Thanks for your answers to all of this...

CdeV
 
If each thread owns its own session, then you can set ThreadSafe to False. All threads can access the database simultaneously.

If multiple threads access the same TOracleSession instance, then you must set ThreadSafe to True. All database access operations will be serialized in this situation.
 
Originally posted by Marco Kalter:

If multiple threads access the same TOracleSession instance, then you must set ThreadSafe to True. All database access operations will be serialized in this situation.
Ok thanks. Let's see a short example :

I have 2 TOracleSession and one of them is accessed by several threads but the second one is accessed only by an unique thread simultaneously.
Can I set ThreadSafe to True for the first OracleSession and Threadsafe to False for the second one? In this case, does a query.execute on the first session (threadsafe) lock/suspend access to the second session?
 
Can I set ThreadSafe to True for the first OracleSession and Threadsafe to False for the second one?
Yes.
In this case, does a query.execute on the first session (threadsafe) lock/suspend access to the second session?
No. Separate sessions will never block each other, unless they want to lock the same database object or record on the server.
 
Thanks a lot Marco. It was exactly what I wanted to know : Separate sessions will never block each other. The synchronization will occur only between threads trying to access the session, without blocking the main thread...
 
Back
Top