0
A
回答
0
查阅关于NSThread
,NSOperationQueue
的文档以及为NSObject
定义的各种performSelector...
方法。
0
一个例子来运行一个子线程:
- (void)threadRun
{
// One thread, one autorelease pool. as main thread's pool inside main.c
NSAutoreleasePool *aPool = [[NSAuroreleasePool alloc] init];
// do-job in thread here
[aPool release];
}
- (void)performJobWithThread
{
// Method 1:
NSThread *aThread = [[NSThread alloc] initWithTarget:self
selector:@selector(threadRun)
object:nil];
[aThread start];
/// Release aThread at some point avoid memory leak.
// Method 2:
[NSThread detachNewThreadSelector:@selector:@selector(threadRun)
toTarget:self
withObject:nil];
}
使用NSThread之前,有更好的阅读Threading Programming Guide第一。它会告诉你关于内存管理,与其他线程的通信,...等。
NSOperation和NSOperationQueue很好地设计多线程。但我现在正在学习它们,我无法清楚地谈论它们。
相关问题
- 1. Cocos2D-iPhone中的多线程OpenGL编程
- 2. iphone多线程API
- 3. IPad,IPhone中的多线程支持
- 4. iPhone“多线程”问题
- 5. Iphone多线程和AI
- 6. iphone网络多线程
- 7. iPhone多线程搜索
- 8. iPhone dev多线程,NSAutoreleasePool
- 9. java中有多线程的多线程
- 10. 面向iPhone/iPad的多线程库
- 11. iPhone的多线程操作通讯录
- 12. iPhone - Tableview多线程 - 可行的方法?
- 13. 关于iPhone上的多线程
- 14. iPhone应用程序中的多线程问题?
- 15. iPhone核心数据和多线程
- 16. iphone网络cfsocket回调多线程
- 17. 使用XCode为iPhone实现多线程
- 18. Iphone:传递对象和多线程
- 19. iPhone多线程:列表/队列
- 20. iPhone - 线程
- 21. iphone/objective-c dev中有多少线程太多
- 22. 在iPhone应用程序中的线程后调度线程
- 23. 关于多线程的java多线程
- 24. 多线程如何在iPhone上的Objective-C中工作?
- 25. iPhone:在多线程环境中释放UIViewController的问题
- 26. iPhone - 使用游戏中心的在线多人游戏教程
- 27. iphone:线程问题?
- 28. iphone线程同步
- 29. iPhone线程问题
- 30. Iphone线程优先
谢谢你的回答,这可能会帮助我... – sandeep 2010-09-03 06:14:37