Send feedback
Lock Service
Stay organized with collections
Save and categorize content based on your preferences.
Lock
This service allows scripts to prevent 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.
Classes
Name Brief description
Lock
A representation of a mutual-exclusion lock.
LockService
Prevents concurrent access to sections of code.
Methods
Method Return type Brief description
hasLock()
Boolean
Returns true if the lock was acquired.
releaseLock()
void
Releases the lock, allowing other processes waiting on the lock to continue.
tryLock(timeoutInMillis)
Boolean
Attempts to acquire the lock, timing out after the provided number of milliseconds.
waitLock(timeoutInMillis)
void
Attempts to acquire the lock, timing out with an exception after the provided number of
milliseconds.
Methods
Method Return type Brief description
getDocumentLock()
Lock
Gets a lock that prevents any user of the current document from concurrently running a section
of code.
getScriptLock()
Lock
Gets a lock that prevents any user from concurrently running a section of code.
getUserLock()
Lock
Gets a lock that prevents the current user from concurrently running a section of code.
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-08-11 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?
{
"lastModified": "Last updated 2021-08-11 UTC.",
"confidential": False
}