Objective-c threading and cpu performance
===

I have an app which downloads some files from the server in few threads. The problems is that it is giving a heavy load to the CPU (hitting to 80%). What can be done to make it better? I made similar app on Windows with C#, and the cpu usage never goes above 5%.

This is how I start the job:

    for (int i = 0; i < 6; i++)
    {
        [NSThread detachNewThreadSelector:@selector(downloadChunk:) toTarget:self withObject:download];
    }

This is the CPU consuming code:

        NSURL *fileURL = [[NSURL alloc] initWithString:[downloadFile filePath]];
        NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:fileURL];
        NSString *range = [NSString stringWithFormat:@"bytes=%lli-%lli", [downloadChunk startingByte], [downloadChunk endingByte]];
        [theRequest setValue:range forHTTPHeaderField:@"Range"];
        NSURLResponse* response;
        NSData *result = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];
        
        NSOutputStream *stream = [[NSOutputStream alloc] initToFileAtPath:chunkPath append:YES];
        [stream open];
        [stream write:[result bytes] maxLength:[result length]];
        download.downloadedBytes += [result length];
        [stream close];