How can I keep my Mac awake AND locked?
In System Preferences > Energy Saver, check the box for "Prevent computer from sleeping automatically when the display is off" (on laptops, this is under the Power Adapter tab)
In System Preferences > Security &amp; Privacy, check the box for "Require password after sleep or screen saver begins" and set the delay in the dropdown menu to "immediately"


Now, you can hit command-option-power to turn off the display without sleeping the computer, and doing anything that turns on the display (like hitting a key or clicking a mouse button) will prompt you for your account password.

On newer macs without the eject key, please use control-shift+power instead.