Describe your approach to handling thread synchronization and avoiding deadlocks in a multi-threaded system.