I have two scheduled TimerTasks running in two java.util.Timer threads and these tasks share a common database connection pool using synchronized methods. Program runs very very slow and I could not notice any thread locks. But the same program run very fast when two separate database connection is maintained by each TimerTask. I have not seen any examples like this, but theoretically it should work. But I don't understand why program takes more time while sharing resources.
Well, we do have a "Blatant Advertising" forum here, and posts that are blatant advertising do get moved over there. But advertising in people's sigs is another question. If they aren't too blatant then we (the bartenders and sheriffs) are going to let them slide by.
However other ranchers are perfectly free to express their own opinions (in a nice way, of course).
Just some random ideas ... don't be offended if they're too simple minded ...
How long do you figure you stay in the synchronized blocks? Your threads will have to go through those single file so they can slow you down.
You wouldn't have a connection pool with one connection in it would you? If there are as many or more connections than threads there should always be one available. Unless maybe you forgot to put them back and the pool was creating new ones all the time.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Jul 23, 2004
Yes, I removed the signature not to offend some ranchers and is adding it back as not every body is offened.. Sorry I can't make everybody happy..
Now.. Back to the point...
Connection pool (based on Apache dhcp ) is pre created with 5 connections. Each thread (total 2) take one connection, fire some sqls and close it.
The threads are Timer Threads and is running separate TimerTasks. The connection is taken from the TimerTasks.