The lockManager interface provides in memory locking services via the following methods:
lock()
, locks a specified resource id so that it can't be accessed by another user
unlock()
, unlocks a resource id so that it can be accessed by another user
// check if a lock has been taken out
if(system.lockManager.lock("exam_answers", "exam_id")){
// do something
// unlock resource once finished
system.lockManager.unlock("exam_answers", "exam_id");
}