Or the connection object should never be synchronized.........
If yes, is there a good approach to implement the same....
Try Try Try...
stu derby
Ranch Hand
Joined: Dec 15, 2005
Posts: 333
posted
0
The only reason to sycnhronize a connection object would be if you were sharing it among multiple threads. Sharing a single connection among multiple threads is a very very very very bad idea.
So no, don't allow more than one thread to use an open connection and then you don't have to synchronize.
If you decide to ignore this advice and allow multiple threads to use a connection object, then only only thread at a time can use the object while it is open, which of course you could accomplish with synchronization. This will make your programmer between 100 and 1,000,000 times slower for some operations though (if it's multi-threaded). Like I said, a very bad idea.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.