Subject Re: [firebird-support] Firebird 25 thread safety
Author Kjell Rilbe
Michael Ludwig skriver:
> ma_golyo schrieb am 21.01.2011 um 13:54 (-0000):
> >
> > From the documentation : "The client libraries, including the embedded
> > one, can now be used in multi-threaded applications without any
> > application-level synchronization."
> > What does this exactly mean?
>
> > #1 : Can I use only a single connection accessing by multiple
> > transactions from different threads at the same time?
>
> That won't work. Think about it. There's a connection used by thread A
> for query X. At some random point in the middle of a transaction, let's
> say thread A has fetched the first 20 out of perhaps 123 records, the
> OS passes control to thread B. Well, thread B also has a reference to
> the connection but is totally unaware of the work performed on that
> connection by thread A. So when thread B merrily calls prepare() or
> what not on the connection, it'll trigger an exception.

1. Why would you assume that the threads don't know what the other
threads are doing? It's quite possible to sommunicate that info between
threads.

2. Thread B would call prepare on a statement, not a connection, right?
So, thread B might very well use the same connection to start a
transaction, while thread A has its transaction active, and the prepare
a new statement under that new transaction. Or am I missing something?

> > #2 : Can I use only a single transaction accessing by multiple
> > "querys" from different threads at the same time?
>
> I think this is about the same as #1.

I think you didn't answer the OP's question. Sorry. No offense. I just
hope someone else will try to explain this a bit better.

Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64