Using locks in ERPNext for background tasks

Hi,
I am struggling to understand how one can make use of locks with ERPNext development. In short, I am trying offload some of the work to background, so it will be handled by more than one worker thread at a time. Since they are accessing/updating the same doctype table, I need to make sure only one of them is using it by making use of some locks. In normal programming it is trivial, by adding some locks to the class. However adding a lock to init() doesn’t seem to help. frappe.get_doc() is creating a new instance of the DocType everytime, so it doesn’t work nicely with multi-threading. Does anyone have any idea as how to restrict the access to a doctype by multiple threads at the same time?