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

  • Home
  • SEARCH
  • 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 6083555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:25:00+00:00 2026-05-23T11:25:00+00:00

I have a class that is accessed from multiple background threads, potentially at the

  • 0

I have a class that is accessed from multiple background threads, potentially at the same time. I cannot copy the class because it’s contents is potentially expensive to recreate (processing or memory-wise).

It is also possible that a property of this class is replaced while processing in the background is still going on and accessing this property.

At present I have regular retain/releases but it seems to be the case (at least on iOS 4) that these are not thread-safe because even though they are perfectly pairs it apparently occurs that the retainCount drops randomly and eventually this class gets deallocated.

I’m looking for suggestions on how to make this class thread-safe, permit concurrent access of properties and permit for a property to be modified while an “earlier version” of the property is still held onto by one of the background actions.

  • 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-23T11:25:00+00:00Added an answer on May 23, 2026 at 11:25 am

    Retain and release are atomic. Autorelease is not. Think of retains as per-thread; if thread A is holding a retain (or a retain/autorelease), then thread A’s reference will be valid until that retain is balanced (or the autorelease pool is drained).

    Autorelease can never be used as a cross-thread ownership transfer primitive.

    Beyond that, hard to say what is going wrong in your app without more code.

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

Sidebar

Related Questions

I have a class that is accessed from multiple threads. Both of its getter
I have some code that will be accessed from two threads: class Timer{ public:
I have an instance of a class that can be accessed by multiple threads.
I have a Singleton that is accessed in my class via a static property
I have a class which should be declared globally from main() and accessed from
Coming from a Delphi background, I am used to be able to have class
I have a DBApdater class that is accessed through many AsyncTasks . Each operation
I have class that represents users. Users are divided into two groups with different
I have class method that returns a list of employees that I can iterate
I have a class that I want to use to store properties for another

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.