# async.yield (Shared)

> Pauses the current async thread until the scripts' next update, to split long work into pieces.

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Shared
- **Category**: Timers and async
- **URL**: https://wiki.mymp.gg/en/async.yield

## Syntax

```lua
nil|false async.yield()
```

## Returns

Nothing when the thread resumes. Only works inside an async thread. Outside one, it logs an error and returns `false`.

## Example

```lua
async.thread(function()
    for i, vehicle in ipairs(getElementsByType("vehicle")) do
        setElementData(vehicle, "checked", true)
        if i % 100 == 0 then
            async.yield()
        end
    end
end)
```

## See also

- [async.wait (Shared)](https://wiki.mymp.gg/en/async.wait.md): Pauses the current async thread for ms milliseconds. The rest of the game keeps running.
- [async.thread (Shared)](https://wiki.mymp.gg/en/async.thread.md): Runs a function in a new async thread, right away. The call returns when the function ends or first pauses, as with async.wait.
