How To Handle Deadlock In Threads