Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7503065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:05:36+00:00 2026-05-29T21:05:36+00:00

I need to do multiple web requests and want it to be fast. The

  • 0

I need to do multiple web requests and want it to be fast. The amount of data is very small, but the server uses some time to answer so I am thinking about using multiple threads. The problem is how to handle the return values. I don’t know if this works:

- (void)findAuthorsForBookIDs:(NSArray*)bookIDs
{
    for (NSString* thisBookID in bookIDs)
    {
        [NSThread detachNewThreadSelector:@selector(findAuthorForBook:) toTarget:self withObject:thisBookID];
    }
}

-(void)findAuthorForBook:(NSString*)thisBookID
{
    NSString *downloadString = [NSString stringWithFormat:
                                    @"http://somewebsite.com/Mediator?bookIDNo=%@", 
                                    thisBookID];

    NSURL *downloadUrl = [NSURL URLWithString:downloadString];

    NSURLRequest *urlRequest = [NSURLRequest requestWithURL:downloadUrl];

    NSError *error;
    NSURLResponse *response;

    NSData *urlData = [NSURLConnection sendSynchronousRequest:urlRequest 
                                     returningResponse:&response
                                                 error:&error];

    NSString *html2;

    if (urlData) 
    {
        html2 = [[NSString alloc] initWithData: urlData encoding: NSISOLatin1StringEncoding];
    }

    [self findAuthorForBookDidFinishWithAuthor:html2 andBookID:thisBookID];


} 

-(void)findAuthorForBookDidFinishWithAuthor:(NSString *)authorName andBookID:(NSString *)bookID
{
    [[self bookList]setValue:authorName forKey:bookID];
}

I do not know if the [self bookList] will handle this? Should I use some locks or something?

EDIT

I have done some reading and wonder if this is what I need to do?

NSLock *myLock = [[NSLock alloc]init];

-(void)findAuthorForBookDidFinishWithAuthor:(NSString *)authorName andBookID:(NSString *)bookID
{
    [myLock lock];
    [[self bookList]setValue:authorName forKey:bookID];
    [myLock unlock];
}

Pls comment, don’t just ‘minus one’ me even if I’m a complete jerk 🙂 Minus one doesn’t tell me much. (Other than that I’m far out)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T21:05:38+00:00Added an answer on May 29, 2026 at 9:05 pm

    There is no performance benefit to doing this with threads rather than NSURLConnection. You can open multiple simultaneous requests without threads. Typically, however, the latency is connecting to the server is the biggest performance obstacle on mobile devices. If you can keep a single connection up, things will go faster. NSURLConnection will do some of this automatically using HTTP/1.1 connections if you let it (i.e. if you don’t fight it by doing your own threading). Opening many simultaneous connections is unlikely to help you very much, however, unless the server is extremely slow to respond to each one but is still capable to processing many in parallel (this is a very rare situation).

    You may also look at MKNetworkKit, which includes several tools for helping you manage simultaneous requests.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my project need to read multiple web pages at a time(eg: for a particular
I need to be able to select multiple options on a web form, but
I need to generate multiple random values under SQL Server 2005 and somehow this
I need to export multiple data tables to Excel on the clients machine, each
I want to send some data to a user after they log in to
I'm writing a web site that uses multiple web services with throttle restrictions. I.e.
I have small file (100) lines of web request(apache std format) there are multiple
For my web app i need to handle access requests. Requests are entered for
I have a program in Perl I'm working on where I would need multiple
I am developing LOB application, where I will need multiple dialog windows (and displaying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.