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 6855033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:42:25+00:00 2026-05-27T01:42:25+00:00

I want to know why I can’t run the button action in secondary thread(see

  • 0

I want to know why I can’t run the button action in secondary thread(see below the secondary thread code), when I do so the APP gets crashed and shows me the below error message.

NSThread *thread = [[NSThread alloc]initWithTarget:self selector:@selector(insertdata) object:nil];
[thread start];

void _WebThreadLockFromAnyThread(bool), 0x6a8cfe0: Obtaining the web lock from a thread other than the main thread or the web thread. UIKit should not be called from a secondary thread.

bool _WebTryThreadLock(bool), 0x6a8cfe0: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...

1   WebThreadLock
2   -[UIFieldEditor setText:andSetCaretSelectionAfterText:]
3   -[UITextField setText:]
4   -[XYZ reset]
5   -[XYZ insertdata]
6   -[NSThread main]
7   __NSThread__main__
8   _pthread_start
9   thread_start

But when I change the thread to main thread(see below main thread code) I don’t see any crash and my APP runs perfectly. Can anyone explain what is the difference, why I cannot run the action secondary thread.

[self performSelectorOnMainThread:@selector(insertdata) withObject:nil waitUntilDone:NO];

Thanks.

  • 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-27T01:42:26+00:00Added an answer on May 27, 2026 at 1:42 am

    The error messages told you the exact reason:

    Obtaining the web lock from a thread other than the main thread or the
    web thread. UIKit should not be called from a secondary thread.

    If the operation doesn’t take long, there’s no point in executing it on a background thread. If the operation does take long, you should separate the data retrieval (or whatever it is that takes long) from the UI update, run the data retrieval in background and then return back to the main thread to update the UI. Preferably using GCD:

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_NORMAL, 0), ^{
        [self downloadData]; // takes long
        dispatch_async(dispatch_get_main_queue(), ^{
            [self updateUI]; // here you can safely call UIKit
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know i can do something similar to this (not working) code
I want to know how can we perform action when mouse is double clicked
I want to know how can we know the other users of Oracle 10g
I want to know how can I perform VS2008 load test from five different
I want to know how can i fill only certain columns while filling the
I want to know how can I read attachment messages without using scriplets in
I want to know that can mouse click event detects colors or even strings.
I want to know how can i format a number like 2000000 into standard
I just want to know: How can I delete 'log.txt' if the last modification
I'm learning PLT Scheme and I want to know how can I build a

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.