I was asked this question in Microsoft for their Azure team based in Bangalore. I was a bit rusty in the answers and could not manage to clear it. Would like to know if peek and isempty operations on stack need locking?
Design a thread-safe stack class. What all operations would you need to lock:
What if you design a stack using two queues. How would you implement the locking then?