Added loop and thread state management in lwc