Why not let the program do its own locking if it needs it? Numbers are used a lot, and opening/closing a lock for every single operation would be pretty expensive.
Locking as close to the resource as possible is easier and usually safer (less chance of missing something) than locking at a higher level, but it's much more resource intensive.