Google Apps Script

Class LockService

Prevents concurrent access to sections of code. This can be useful when you have multiple users or processes modifying a shared resource and want to prevent collisions.

Methods

MethodReturn typeBrief description
getPrivateLock()LockGets a lock that prevents the current user from concurrently running a section of code.
getPublicLock()LockGets a lock that prevents any user from concurrently running a section of code.

Detailed documentation

getPrivateLock()

Gets a lock that prevents the current user from concurrently running a section of code. A code section guarded by a private lock can be executed simultaneously by different users, but by no more than one execution for any given user. The lock is "private" to the user. Note that the lock is not actually acquired until Lock.tryLock(timeoutInMillis) or Lock.waitLock(timeoutInMillis) is called.

Return

Lock — a private lock


getPublicLock()

Gets a lock that prevents any user from concurrently running a section of code. A code section guarded by a public lock cannot be executed simultaneously regardless of the identity of the user. Note that the lock is not actually acquired until Lock.tryLock(timeoutInMillis) or Lock.waitLock(timeoutInMillis) is called.

Return

Lock — a public lock

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.