Software Engineering
← All questionsAn online shop has one unit of an item in stock. Two customers check out at the same moment; both requests read the stock as 1, both decide the sale is allowed, and both write the stock down to 0, so the single item is sold twice. Why did this happen, and how would you change the code so it cannot oversell?
Start with your best guess. One sentence is enough.