i'm new ios and i don't know performance of NSThread an multithread on IOS. I've a function
-(void) writeBlock:(NSString *)srcPath toPath:(NSString *)destPath fromIndex:(int)fIndex toIndex:(int)tIndex
{
//create file handle for srcPath and destPath
for(int i=fIndex;i<=tIndex;i++){
//read from source filehandle
//write to dest filehandle
}
//close filehandle.
}
If i create a single thread for above function,the time for perform this function is 1 second. But when i create:
for(int i=0;i<20;i++)
{
[NSThread detachNewThreadSelector: @selector(writeBlock:) toTarget:self withObject:myObject];
//for each thread, tIndex-fIndex is the same with tIndex-fIndex of single above thread
}
The time for perform 20 threads is 13-16seconds. I think the time will be 1-5 seconds.Multi thread is slow? Can anyone help me?Thanks so much