Multiuser Lingo Dictionary > Multiuser Lingo Dictionary > lock() |  |

lock()

Syntax

    lock(whichObject)

Description

Multiuser Server server-side command; locks the given data object so that other threads may not make changes to the object until the `unlock()` command has been called. Lockable data objects include lists and property lists.

If another thread attempts to lock the same data object, it is blocked until the thread originally placing the lock explicitly unlocks the object via the `unlock()` command.

This command returns `1` if it places the first lock on the object, `2` if another thread has already locked the object.

Note: A list object will be automatically unlocked if a thread both locks the list and then resets the list to a new list value. The lock stays in effect only when individual values inside the list are edited.

Example

This `lock()` statement occurs in a separate thread and locks the list object `theList`, which has been defined earlier in the default server thread.

    lock(theList)

See also

`unlock()`, `wait()`