easiest way to lock you screen but not logout.
Step 1: Open Keychain Access by short cut of In spotlight (cmd + space) write “Keychain Access”
step 2: select preferences
step 3: select “General” Tab and select “Show keychain status in menu bar”
step 4: Now you can show the lock on top left menu bar
Now select Lock screen and enjoy work.