Reputation: 3652
Ok, I have just realized this issue.
Let say you use Java + Tomcat to build ur web App.
The Tomcat receives 2 call from 2 clients at the same time. The 1st call (will call a series of methods & return an integer) is received by the server before the 2nd.
Call1:
String passwordProvidedByUser=action.getPasswordFromClient();
String passwordFromDB=data.getPasswordFromDB();
if (passwordFromDB.equals(passwordProvidedByUser)){
boolean updated=data.updateInfo();
}
Call 2:
String newPassword=action.getPasswordFromClient();
boolean changePwd=data.changePwd(newPassword);
So, if Call1 finished String passwordFromDB=data.getPasswordFromDB();
but has not run the boolean updated=data.updateInfo();
while call 2 already ran boolean changePwd=data.changePwd(newPassword);
. That means call 1 boolean updated=data.updateInfo();
with old password?
My question is that will Tomcat server/Java finish all the actions of 1st call & return the result to the 1st call before it starts to process the 2nd?
Or the Tomcat server/Java just starts to process the 2nd while it is still processing the 1st (ie the server hasn't return a result to the 1st, but already started to process the 2nd)?
Upvotes: 0
Views: 99
Reputation: 32517
Every call goes on queue from where it is picked up by workers threads for processing - yes, there is pool of threads that are responsible for processing requests so the order of request handling is rather undetermined.
Upvotes: 2