lock and unlock of resources