Question about threads garbage collecting

I can’t find an answer to this question anywhere else. I may just suck at searching, but I have not seen anybody talking about whether or not threads garbage collect after being completed.

Right now, I’m stuck with trying to cancel threads inside themselves (which I don’t think can even work), but knowing whether or not this happens would help a lot.

	local thread
	
	thread = task.spawn(function()
		for s, service in pairs(services) do
			--hidden
		end
		
		for s, service in pairs(services) do
			--hidden
		end
	end)

I’m pretty sure they do, but I use task.cancel(<thread>) after I’m done with the thread, just in case lol

I tried that, but it said i couldn’t cancel the thread. For some context, I tried running it from inside the thread itself…

That may be because the thread is nil, try doing print(typeof(thread))

1 Like