Destroy Citizen.CreateThread()?

Is it possible to destroy a thread and if it is then how?

1 Like

You mean destroy the ‘while true do’ loop or the actual thread?

I assume (could be completely wrong) that the scheduler or w/e automatically deletes the thread if it is no longer being used (like not in a while true loop, but just execute some code and finish).

Anyone know if that’s correct?

This is also my assumption, although if it is a ‘while true do’ loop you can use ‘break’ to break it

1 Like

I don’t think you can delete a thread but you can stop it from running like james said.

Can use break or return

Was it ever confirmed that this is how threads behave? Deleted when the code in them is done?

Yes.
When you return from the function, and that is the only reference to it, the function gets garbage collected.
If there are still references, it will stay in memory, but will no longer run.

1 Like

Thank you.