Creates a new thread instance with specified function in suspended state
local instance = util.thread.create(
exec
)
| Type | Name | Description |
|---|
function | exec | Function to execute by the thread |
| Type | Name | Description |
|---|
thread | bool | instance | Created thread instance on successful execution, false otherwise |
| Type | Name | Description |
|---|
thread | self | Running thread instance |
Create and resume a basic thread local entity = util.thread.create(function(self)
core.engine.print("info", "Hello from thread")
end)
entity:resume()
Create a thread and sleep inside it local entity = util.thread.create(function(self)
core.engine.print("info", "Sleeping for 2 seconds")
self:sleep(2000)
core.engine.print("info", "Awake now")
end)
entity:resume()