Page 1 of 1
One session and two thread
Posted: Wed 05 Dec 2012 08:20
by sinys
In my application one session can be used in two threads.
One of the threads has the timer to keep the session in active state besides query.
How to find out it is the moment to make a request to the server to maintain the session (in timer event)? Is there a flag in OraSession telling the session now is occupied for two thread won`t have the possibility to use the same session.
Re: One session and two thread
Posted: Wed 05 Dec 2012 09:19
by AlexP
Hello,
There is no such property in TOraSession that would be responsible for session "occupancy". However, since ODAC is a threadsafe product, you can use one and the same session in different threads without such checks, and this won't lead to errors.
Re: One session and two thread
Posted: Wed 05 Dec 2012 09:50
by sinys
So do you want to say that if two threads ask the session to execute the query, two queries will be processed in the same session at the same time? Or in OraSession will be queue?
Re: One session and two thread
Posted: Wed 05 Dec 2012 12:04
by AlexP
Hello,
In context of one session only one operation can be executed at a time, regardless of how many threads use one and the same session. If at the time the session is "busy", the next operation invoked from another thread will wait for completion of the current operation.
Re: One session and two thread
Posted: Tue 12 Feb 2013 07:47
by a-s-z
Hi,
AlexP wrote:There is no such property in TOraSession that would be responsible for session "occupancy". However, since ODAC is a threadsafe product, you can use one and the same session in different threads without such checks, and this won't lead to errors.
Is direct mode threadsafe too? Documentation says it is not.
Best Regards,
Andre
Re: One session and two thread
Posted: Tue 12 Feb 2013 11:05
by AlexP
Hello,
Yes, full thread-safety is really guaranteed in the OCI mode, we recommend to use a separate connection for each thread in the Direct mode, but you can try using one and the same connection for different threads, since we haven't received complains about thread-safety in this mode recently, and all the known problems are already fixed.