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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:46:09+00:00 2026-05-23T07:46:09+00:00

A ConcurrentBag will allow multiple threads to add and remove items from the bag.

  • 0

A ConcurrentBag will allow multiple threads to add and remove items from the bag. It is possible that a thread will add an item to the bag and then end up taking that same item right back out. It says that the ConcurrentBag is unordered, but how unordered is it? On a single thread, the bag acts like a Stack. Does unordered mean “not like a linked list”?

What is a real world use for ConcurrentBag?

  • 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-23T07:46:10+00:00Added an answer on May 23, 2026 at 7:46 am

    Bags are really useful for tracking instance counts. For example, if you want to keep a record of which hosts you’re servicing web requests for, you can add their IP to the bag when you start servicing the request, and remove it when done.

    Using a bag will allow you to tell at a glance which IPs you’re currently servicing. It will also let you quickly query whether you’re servicing a given IP address.

    If you use a set for this rather than a bag, then having multiple concurrent requests from the same IP address will mess up your record-keeping.

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

Sidebar

Related Questions

I have now a scenario that needs to add and remove items in multi-threading
I have a piece of code that can be executed by multiple threads that
With the new ConcurrentBag<T> in .NET 4, how do you remove a certain, specific
I have been using Java's ConcurrentMap for a map that can be used from
I have a collection of objects that is modified by one thread and read
I find myself very intrigued by the existence of a ConcurrentBag<T> class in the
What is the advantage of using a ConcurrentBag(Of MyType) against just using a List(Of
I'm looking for an ExecutorService implementation that can be provided with a timeout. Tasks
Description of ConcurrentBag on MSDN is not clear: Bags are useful for storing objects
Quick background I have a concurrent map I used to cache some values that

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.