Locking your computer screen
If you want to stay logged in to your computer while you are away from it, but need to prevent others from using it, you can lock the screen. When you return to the computer, type your login name and password to continue working.
Open System Preferences, and then click Security.
Select “Require password to wake this computer from sleep or screen saver.”
A person with an administrator account can use their name and password to unlock the screen.
Locking the screen does not prevent other users from turning off the computer and restarting it, then logging in to their own account. If you think this could happen, be sure to save your work before you leave your computer.
If your computer has multiple users and you want more than one user to stay logged in at a time, select “Enable fast user switching” in the Accounts preferences. To lock your screen quickly with fast user switching enabled, choose Login Window from the menu with your username. You applications will remain open and undisturbed but your computer will be locked.