[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Terminating a Thread from another Thread - current_act() missing?
- Subject: Terminating a Thread from another Thread - current_act() missing?
- From: nigel at ind.tansu.com.au (nigel@xxxxxxxxxxxxxxxx)
- Date: Mon Mar 4 21:46:59 2002
- In-reply-to: <200203021319.g22DJ0x28003@lists.omnigroup.com> from "macosx-dev-request@omnigroup.com" at Mar 02, 2002 05:19:00 AM
Someone asked:
> I am unable to figure out how to terminate a thread from another thread.
> When I attempt to use thread_abort(), I am unable to find compatibility for getting the value to pass this function.
Timothy wisely councilled:
> You can just call shutdown() and/or close() on the socket and accept()
> should return an error code in the other thread. Much cleaner than
> blowing the other thread out of the water :)
Of course, if someone does have a valid reason for
killing a thread, something like this is all you need:
#import <mach/mach.h>
#import <mach/kern_return.h>
// In the created thread:
thread_t machThread = mach_thread_self();
...
// In the murdering thread:
thread_terminate(machThread);
thread_suspend() and thread_resume() have also been very
useful to me.
--
| Nigel Pearson, nigel@xxxxxxxxxxxxxxxx | "Things you own |
| Telstra iDevelopments, Sydney, Australia | end up owning you" |
| Office: 9206 3468 Fax: 9212 6329 | "not a beautiful snowflake" |
| Mobile: 0408 664435 Home: 9792 6998 | Tyler - Fight Club |