Hey, I was just wondering if there was some way to remove a thread after it finishes. I want to do this because:
(a.) Two threads can't have the same name. Unusable threads are a waste of space.
(b.) I can't use thread:start() to restart the thread until 0.9.0 ):
(c.) I hate the finished thread's guts and I want it to burn in a firey death.
Removing Threads
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Removing Threads
wats a lau?
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Removing Threads
You need to wait on it for it to get cleaned up.
Re: Removing Threads
Alright, thanks for clearing that up. It wasn't exactly clear in the wikibartbes wrote:You need to wait on it for it to get cleaned up.
wats a lau?
Re: Removing Threads
I guess garbage collection takes care of it? In that case, you have to make sure you don't have any references to it, just like any other object.
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
Re: Removing Threads
It seems that if I call :wait() on the finished thread and then :start() directly after, it restarts the thread rather than cleaning it up. Is this intended behavior?
wats a lau?
Re: Removing Threads
Well, you kept the reference, so how did you expected thread to get cleaned?
Re: Removing Threads
Hmm. If I use return at the bottom of a thread, does it empty the thread's message pool?
wats a lau?
Re: Removing Threads
To get rid of reference? Erm, no.
Code: Select all
mythread = nil
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Removing Threads
It doesn't. There's an implicit return anyway. That said, when the thread object is garbage collected, then it will destroy the messages with it.Eversome wrote:Hmm. If I use return at the bottom of a thread, does it empty the thread's message pool?
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 4 guests