Apple keeps working on making Xcode more stable all the time. While Xcode 4.6 has much improved in terms of simply quitting on you, people report that more often now they see Xcode just hang.
One method to deal with race conditions in a highly parallelized application like Xcode is to add semaphores and locking. Unfortunately locking is not the end-all of all all Xcode problems, even with a liberal sprinkling. A blocked main thread is a blocked main thread.
Here is what you should do next time you encounter the beach ball of doom.