Questions tagged [concurrent-collections]

Concurrent Collections are several collection implementations in .Net that support multi-threaded access in a safe and efficient way

Concurrent Collections are several collection implementations in .Net that support multi-threaded access in a safe and efficient way. Some of those collections are ConcurrentQueue, ConcurrentStack, ConcurrentBag.

References

98 questions
11
votes
3 answers

Performance comparison of ConcurrentBag vs List

Preface: I'm only asking this because I don't have an environment (dataset large enough + computing power) to test it in a reliable fashion. Question: Given a ConcurrentBag, loaded with billions of items, being accessed/used by a single thread,…
Leonardo
  • 10,737
  • 10
  • 62
  • 155
11
votes
1 answer

Usage of ConcurrentQueue>

I am basically looking for a container of image collections acquired from camera in a thread. Since ConcurrentQueue is thread-safe, I wanted to use it. But while debugging my code, I found this article saying If the elements are small, you’ll…
Tae-Sung Shin
  • 20,215
  • 33
  • 138
  • 240
10
votes
4 answers

How to access the underlying default concurrent queue of a blocking collection?

I have multiple producers and a single consumer. However if there is something in the queue that is not yet consumed a producer should not queue it again. (unique no duplicates blocking collection that uses the default concurrent queue) if…
9
votes
4 answers

How to sort a concurrent collection in .NET 4.0

How to sort a concurrent collection in .NET 4.0 For example I have constructed my ConcurrentBag collection. How can I sort the elements in it? ConcurrentBag stringCollection; ConcurrentBag customCollection;
mitul patel
  • 101
  • 1
  • 1
  • 3
9
votes
2 answers

What's the 'mostly-concurrent garbage collector'?

I know concepts of stop-the-world, incremental, parallel, concurrent, (soft/hard) realtime garbage collectors. But I can't understanding mostly-concurrent GC. Is it different with concurrent GC? What's the difference? Why it is called mostly?
eonil
  • 83,476
  • 81
  • 317
  • 516
9
votes
2 answers

What thread-safe collection classes are available in Silverlight 4?

I am developing an application framework that will be utilized by Silverlight on the client side and .NET 4 on the server side. Internally, the framework has dictionary and queue data structures where multiple threads will be accessing the…
Oppositional
  • 11,141
  • 6
  • 50
  • 63
7
votes
4 answers

When immutable collections are preferable than concurrent

Recently read about immutable collections. They are recommended to be used as a thread safe for reading, when the read operations are performed more often than write. Then I want to test read performance ImmutableDictionary vs ConcurrentDictionary.…
xneg
  • 1,204
  • 15
  • 24
7
votes
1 answer

Using AddOrUpdate method in ConcurrentDictionary in .NET 4.0

I am facing troubles in Concurrent collections and threading, specifically using the AddOrUpdate method in ConcurrentDictionary basically..... I am not able to put it into use.. I couldn't find any good example on it... and also couldn't understand…
Cheshta
  • 71
  • 1
  • 1
  • 2
7
votes
1 answer

C# throttling For loop

Initial Situation I'm developing a .NET Framework 4.0, C#, Winform Application. The Application will list (and test) WebServiceOperations in a GridView (with currently 60 DataRows => WebServiceOperations). Objective I have to test/call all of this…
Christian Casutt
  • 2,334
  • 4
  • 29
  • 38
7
votes
1 answer

When to use ConcurrentHashMap

Possible Duplicate: What’s the difference between ConcurrentHashMap and Collections.synchronizedMap(Map)? I was reading differences between HashMap, Collenctions.synchonizedMap and ConcurrentHashMap. My understanding is that…
mehta
  • 735
  • 1
  • 11
  • 26
6
votes
2 answers

Concurrent collections and unique elements

I have a concurrent BlockingCollection with repeated elements. How can modify it to add or get distinct elements?
6
votes
1 answer

Why doesn't Collections.Generic.Queue have Synchronized method but Collections.Queue has?

System.Collections.Queue class has Queue.Synchronized method which returns a thread-safe Queue implementation. But the generic one, System.Collections.Generic.Queue does not have a Synchronized method. At this point I have two questions in…
ahmet alp balkan
  • 42,679
  • 38
  • 138
  • 214
6
votes
2 answers

Producer/consumer pattern with a fixed-size FIFO queue

I need to implement the producer/consumer pattern around a fixed-size FIFO queue. I think a wrapper class around a ConcurrentQueue might work for this but I'm not completely sure (and I've never worked with a ConcurrentQueue before). The twist in…
bmt22033
  • 6,880
  • 14
  • 69
  • 98
6
votes
5 answers

Java collection to allow adding and removing while iterating

I am interested if there is any framework that implements a collection that would have the following behavior. Suppose it initially contains: [1, 2, 3] I iterate it (using an iterator) and reach element 2, now I add 4 to the end (the collection…
Razvi
  • 2,808
  • 5
  • 31
  • 39
5
votes
2 answers

Memory leak in weakValue map reference for synchronized method

I am creating an interface for executing methods concurrently, while abstracting away the synchronization details (To swap for a distributed implementation when needed). I've created a single jvm implementation that allows Strings to be used as the…