Halting Threads
BlitzMax Forums/BlitzMax Beginners Area/Halting Threads
| ||
Hi everyone, I did a quick search of the forum and through the documentation but to no avail. I was wondering whether it was possible to stop threads once they've been started. I see that you can detach a thread but that's about it. Thanks |
| ||
sure, the function that you threaded just needs to return. |
| ||
Ii haven't tried using return, which I'm guessing is much faster, but if you want to pause a thread you could create a placeholder mutex that doesn't lock any actual data, make sure the child thread requests a locking of the mutex, and have the main thread lock it beforehand. Here's an untested code example Child thread Repeat LockMutex(PlaceHolder) UnlockMutext(PlaceHolder) 'All the thread processing goes here. Forever Umm... That code was so short I doubt it helped much. :-D Ayyway, it's just an idea. Get advice from others too. |
| ||
if you are using a loop then try out semaphores use waitsemaphore every loop. This way you can also sync your threads with your main program |
| ||
Thanks guys... that worked really well! |