Title: simultaneous transactions in different threads
Thanks,
 
Getting a new database connection is fine due to the fact I am using pooling. I was worried about any other work that is done (eg if some large amount of memory is used or if the XML file is re-parsed everytime). I don't want to have to influence my design but to work as it is means getting a new database object every transaction I do which might be too expensive.
 
Cheers,
Brett
-----Original Message-----
From: Tim Fox [mailto:[EMAIL PROTECTED]]
Sent: Friday, 21 September 2001 8:23 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] simultaneous transactions in different threads

I believe the Database class is not thread-safe - hence you cannot share an instance between threads.
If you're worried about getting a new connection each time you call getDatabase(), then you should be able to use a database connection pool.
-----Original Message-----
From: Brett Porter [mailto:[EMAIL PROTECTED]]
Sent: 21 September 2001 04:33
To: [EMAIL PROTECTED]
Subject: [castor-dev] simultaneous transactions in different threads

Hi again,

Castor is amply filling my needs up until this point. Looking forward to using it further! Good job to those involved.

The current problem I'm having is accessing transactions from multiple threads. I have several created threads in one thread group. Each thread executes:

db.begin();
db.create( some new object );
db.commit();

The db object is shared among all threads. When they overlap, exceptions are thrown because it can't start a transaction for all but the first thread.

Does this mean I have to jdo.getDatabase() for each thread? What is the overhead involved in this?
Esentially because of the application's design this will mean each transaction gets a new instance of the database, which could be very expensive.

I have looked at the code in CVS - I expected only to see the getDatabase() call getting a new connection to the actualy database but it appears to me to be doing a whole lot more so I'm not sure if it is such a good idea.

Regards,
Brett

~*~*~*~*~*~*~
Brett Porter
Web Developer, f2 Fairfax Interactive Network, Australia
Ph: +61 2 8596 4437
Email: [EMAIL PROTECTED]

Reply via email to