Xoriant Interview Question

I was asked to implement a question related to multithreading