Posted on 2006-04-25
Last Modified: 2013-11-20
I have a CObArray that I'm access from 2 different threads, one thread is suppose to be updating it and the other one only reads from it.  Is there a way to change data in it.  As of right now, I'm pulling to object out and updating the object.  I will then use RemoveAt and InsertAt to update the object in the array.  The problem is, if I try to read the item while it has been removed and hasn't been reinserted yet I have nothing to read.
Question by:docieb
    LVL 30

    Expert Comment

    Hi docieb,
    > The problem is, if I try to read the item while it has been removed
    > and hasn't been reinserted yet I have nothing to read.
    You need to add syncrhonization logic to your code, so that the read and write does't occur at the same time.

    David Maisonave (Axter)
    LVL 30

    Accepted Solution

    You could accomplish this automatically by using one of the following synchronized smart pointers:  (Simple version)  (More complex policy base smart pointer)

    The more complex version would require you to specify the synchronization smart pointer policy.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Suggested Solutions

    Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now