How do I know which process is causing my computer to hang?
If you can't launch or switch programs (I find Spotlight is a good way to do this if everything else is hanging, just hit ⌘Space, but it may not work in your case), you could enable SSH access ahead of time, and then use another device to log in and check what's hogging your CPU.

Open Sharing Preferences and enable Remote Login. Then you can connect via SSH from another Mac, PC or iOS device (you'll need PuTTY on Windows, and one of various SSH clients available on iOS). Once you're logged in, type top -o cpu to get an updating display of processes ranked by CPU usage. That should give you a hint as to what's causing the problems.