Mphasis interview question

It was on thread. Write a program on thread. Example, only one thraed should finish task and if thread fail, then another thread should try to complete it. But only one thread should complete task.