开发者

how to kill a blocked thread

开发者 https://www.devze.com 2023-01-06 23:40 出处:网络
Im still kind of new to objective-c and english,I am wondering the following question I c开发者_StackOverflowreated a sub thread for something,but it may be blocked in somewhere.

Im still kind of new to objective-c and english,I am wondering the following question

I c开发者_StackOverflowreated a sub thread for something,but it may be blocked in somewhere.

so I set a timer for 10 secs to kill the sub thread in case that it is blocked.

The question is 'how'

PS:is it possible to user performSelector:onThread:withObject:waitUntilDone: for me.


Instead of just killing a thread that may be blocked for a perfectly good reason, you should try to figure out why the thread is blocking. If it is waiting for a mutex or other kind of lock, then figure out why that lock is not being released. It could be that the reason for the lock may not be in the thread itself, but in some other part of your code.

If you just kill the thread you may end up having other threads blocking since the reason may not have been resolved. Some kind of locks may also be left in a unknown state so you are facing other problems after killing it.

0

精彩评论

暂无评论...
验证码 换一张
取 消