multithreading - handling concurrency for last item in inventory -


we've 1 book left in inventory. , 2 people trying same book ( person x , person y ). person x has added book cart , make payment , person y has added book cart. how solve concurrency problem ?

based on description, looks allowing users add last item cart mean there no hold on item while in cart, can add check during check out, checking item availability database constraint stock can not less 0 in case database transaction fail , return error. can reply message saying item out of stock.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -