killing threads externally
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
killing threads externally
is it possible to kill a thread from the outside? like, say, i make it sleep for 5 seconds, but 2 seconds into its sleep i decide to kill it. since Thread:kill() was removed, what do i do?
hippity hoppity ur code is my property (thanc in advanc)
Re: killing threads externally
Maybe try to use thread:release(), but I am not sure, what it will do…
Otherwise use channels to communicate and divide work into smaller pieces, so that it will check if there are some new messages between tasks.
Otherwise use channels to communicate and divide work into smaller pieces, so that it will check if there are some new messages between tasks.
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: killing threads externally
You send it a message to end itself, and it will... after the 5 second sleep has passed.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: killing threads externally
I don't think all systems support killing a thread, so I'd go with zorg's suggestion.
For extra responsivity, instead of sleeping for 5 seconds, you can loop 50 times sleeping for 0.1 seconds and checking whether a termination request was issued on each iteration.
For extra responsivity, instead of sleeping for 5 seconds, you can loop 50 times sleeping for 0.1 seconds and checking whether a termination request was issued on each iteration.
Re: killing threads externally
By turning off the computer you kill any thread even this forum thread. An odd solution i know. Sorry.
Re: killing threads externally
that was something i considered, but wanted to avoid. what i didn't realize is that it doesn't matter whether the thread terminates during or after the sleep, as it does nothing either way lolpgimeno wrote: ↑Mon May 22, 2023 11:54 am I don't think all systems support killing a thread, so I'd go with zorg's suggestion.
For extra responsivity, instead of sleeping for 5 seconds, you can loop 50 times sleeping for 0.1 seconds and checking whether a termination request was issued on each iteration.
hippity hoppity ur code is my property (thanc in advanc)
Who is online
Users browsing this forum: Amazon [Bot], Bing [Bot], Google [Bot] and 1 guest