利用NSThread创建新线程

 

detachNewThreadSelector:toTarget:withObject:

Detaches a new thread and uses the specified selector as the thread entry point.

+ (void)detachNewThreadSelector:(SEL) aSelector toTarget:(id) aTarget withObject:(id) anArgument
Parameters
aSelector

The selector for the message to send to the target. This selector must take only one argument and must not have a return value.

aTarget

The object that will receive the message aSelector on the new thread.

anArgument

The single argument passed to the target. May be nil.

Discussion

For non garbage-collected applications, the method aSelector is responsible for setting up an autorelease pool for the newly detached thread and freeing that pool before it exits. Garbage-collected applications do not need to create an autorelease pool.

The objects aTarget and anArgument are retained during the execution of the detached thread, then released. The detached thread is exited (using the exit class method) as soon as aTarget has completed executing the aSelectormethod.

If this thread is the first thread detached in the application, this method posts theNSWillBecomeMultiThreadedNotification with object nil to the default notification center.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值