Stay organized with collections Save and categorize content based on your preferences.
LockServicePrevents 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 Method Return type Brief descriptiongetDocumentLock()
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. Detailed documentation getDocumentLock()
Gets a lock that prevents any user of the current document from concurrently running a section of code. A code section guarded by a document lock can be executed simultaneously by script instances running in the context of different documents, but by no more than one execution for any given document. Note that the lock is not actually acquired until Lock.tryLock(timeoutInMillis)
or Lock.waitLock(timeoutInMillis)
is called. If this method is called outside of the context of a containing document (such as from a standalone script or webapp), null
is returned.
Lock
— a lock scoped to the script and current document, or null
if called from a standalone script or webapp
getScriptLock()
Gets a lock that prevents any user from concurrently running a section of code. A code section guarded by a script 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.
Lock
— a lock scoped to the script
getUserLock()
Gets a lock that prevents the current user from concurrently running a section of code. A code section guarded by a user 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.
Lock
— a lock scoped to the script and current user
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 2024-12-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[[["`LockService` prevents concurrent access to shared resources in Apps Script, avoiding collisions when multiple users or processes modify them."],["It offers three types of locks: `getDocumentLock()`, `getScriptLock()`, and `getUserLock()`, each with different scopes of access restriction."],["These locks are acquired using `Lock.tryLock(timeoutInMillis)` or `Lock.waitLock(timeoutInMillis)` methods for controlled access to critical code sections."],["Each lock type returns a `Lock` object that provides methods to manage the lock, ensuring data integrity and consistency in shared environments."]]],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4