I have a method
void SaveApplication开发者_JAVA技巧Data()
{
begin transaction
update
insert
commit transaction
}
if two users call this method at same time, can these two database transaction run at same time?
Large numbers of transactions can be running simultaneously. However, if they're updating the same rows, they may well have locking problems, and one or more may be rolled back. (It's a long time since I dealt with conflicting transactions.)
yes they can run at the same time
Make sure of using the proper Isolation Level
No it cannot run at the same time. Let say u have an account having k dollars and in first transaction u requested to withdraw k dollars and in 2nd transaction u requested same. U will get 2 k dollars because u did transaction at same time and your account balance shows k dollars for both transaction. so avoid this i think they use synchronization. without completing the first transaction u cannot go for 2nd and if u go u have to wait till completion of first.
精彩评论