Describe a scenario where a deadlock might occur in a multi-threaded driver, and explain how you would prevent it.