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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:24:04+00:00 2026-05-25T15:24:04+00:00

I am working on a application where huge number of threads are expected to

  • 0

I am working on a application where huge number of threads are expected to iterate over set of string values and try to match it’s own data with the data available in the list.

I am looking for following use case:

  1. Vector is initialized with few elements of type std::string. (Lets say object name is strList). strList will get initialized at the time of application startup.
  2. All threads will iterate over strList to see if it’s value matches with atleast one element of strList.
  3. No thread will ever try to modify strList and it will be strictly used as readonly object.

So could you please tell me if concurrent reads are thread-safe on vector object. I am using RHEL 6 and gcc version is 4.5.x

  • 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-25T15:24:05+00:00Added an answer on May 25, 2026 at 3:24 pm

    YES for the scenario you mention, it is perfectly Thread Safe.


    Actually, STL is not a correct way of referring it.
    It is the C++ Standard Library.

    The C++03 Standard does not talk about concurrency at all, So the concurrency aspect is left out as an implementation detail for compilers. So the documentation that comes with your compiler is where one should look to for answers related to concurrency.

    Most of the STL implementations are not thread safe as such.
    But for concurrent reads of same object from multiple threads most implementations of STL are indeed thread safe.

    References:

    MSDN says:

    A single object is thread safe for reading from multiple threads. For example, given an object A, it is safe to read A from thread 1 and from thread 2 simultaneously.

    The Dinkumware STL-Documentation says:

    Multiple threads can safely read the same container object. (There are nunprotected mutable subobjects within a container object.)

    GCC Documentation says:

    We currently use the SGI STL definition of thread safety, which states:

    The SGI implementation of STL is thread-safe only in the sense that simultaneous accesses to distinct containers are safe, and simultaneous read accesses to to shared containers are safe. If multiple threads access a single container, and at least one thread may potentially write, then the user is responsible for ensuring mutual exclusion between the threads during the container accesses.

    So from the above, Yes it is thread safe in GCC to have concurrent reads of same object from multiple threads.

    Note: GCC’s Standard Library is a derivative of SGI’s STL code.

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

Sidebar

Related Questions

I'm working with an application that has to download a huge amount of data
I am working on an application which reads in a huge amount of data
I am working on a huge web-application with hundreds of dependencies (jar files). I
I've try to implement integration tests for a working application (spring, hibernate, soap, cxf).
I am currently working on an application that parses huge XML files. For each
I have started working on a huge PHP application that has thousands of lines
I am working on an application that takes a huge amount of resources. These
I'm working on a RIA system which has a huge number of static resources.
I am currently working on producing the data model for my application and it
In my application, i have to read a huge amount of data. After i

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.