The OS X menu bar is a central location for accessing system resources in the Apple menu, application-specific menus, and also a number of system settings through menu extras that can be appended to the right side of the menu bar. Some extras that are on by default include the time and date, battery level, and volume control, but others can be added to the bar, including VPN status, keychain, the script menu, and Bluetooth status.
Though these menu extras are convenient, there may be times when problems occur with this part of the system menu, such as freezes and hangs. Typically, only the right-side of the menu bar will hang, so while you can still access the File, Edit, and Apple menus among others to the left of the bar, when you move your mouse to the right you will see it turn to the spinning color wheel or otherwise be nonfunctional.
This problem usually happens because of incompatibilities with third-party menu extras installed on your system. The menu extra feature in OS X is a convenient way for developers to give quick access to their programs' features, and is often used for malware scanners, firewalls and filters, input managers, and network monitors to give you quick updates on their activities.
So, if you are experiencing problems with the menu bar hanging, try first updating any program you have installed that uses the menu bar. A common one that has resulted in menu bar hangs is the popular iStats Menu system monitor, but others may cause issues as well and a quick update should make sure they are the version that's most compatible with your version of OS X.
Another source for menu bar hangs may be problems with the menu bar setup in OS X, so removing the preferences file that manages the menu bar may help. To do this, in the Finder choose "Library" from the Go menu (for Mountain Lion users hold the Option key to reveal the Library in this menu). Then go to the Preferences folder and remove the file called "com.apple.systemuiserver.plist." Then log out and back in to your system.
Do keep in mind that deleting the SystemUIServer preferences file will leave you with a default set of menu extras, so you will have to manually re-enable and rearrange them.
Finally, if a third-party menu extra is simply not compatible and despite being updated is still showing buggy behavior in OS X, then the best approach is to disable this program's menu extra or remove the program from the system. While menu extras are mostly intended to be quick-access options for program settings that can be enabled or disabled, some programs operate entirely through the menu extra or have one that is enabled at all times.
In addition, some programs use an older approach to programming menu extras and so they're treated slightly differently in the menu bar. These extras load after the default menu extras, and are usually appended to the left of the menu extras. A good way to identify these is to try moving them around the menu bar by holding the Command key and then clicking and dragging. If the modern approach to menu extras was used, then this action should allow you to move the menu extra around; if it's an older extra, it will stay put. (Granted, you can only apply this test when the menu bar is not currently hanging.)
This is often an easy way to identify third-party menu extras that may be the source of the problem, so you can then go about testing each by uninstalling, quitting, or otherwise disabling them to troubleshoot the menu hangs you are experiencing.