Made a lot of changes in order to fix the bug. Found out the situation. But bug still remains. Deadlock/livelock also exists need to check for that too.