In C# would it be better to use Queue.Synchronized or lock() for thread safety?

Personally I always prefer locking. It means that you get to decide the granularity. If you just rely on the Synchronized wrapper, each individual operation is synchronized but if you ever need to do more than one thing (e.g. iterating over the whole collection) you need to lock anyway. In the interests of simplicity, I … Read more

Is there a performance difference between pooling connections or channels in rabbitmq?

I have found this on the rabbitmq website it is near the bottom so I have quoted the relevant part below. The tl;dr version is that you should have 1 connection per application and 1 channel per thread. Connections AMQP connections are typically long-lived. AMQP is an application level protocol that uses TCP for reliable … Read more

Python multiprocessing.Queue vs multiprocessing.manager().Queue()

Though my understanding is limited about this subject, from what I did I can tell there is one main difference between multiprocessing.Queue() and multiprocessing.Manager().Queue(): multiprocessing.Queue() is an object whereas multiprocessing.Manager().Queue() is an address (proxy) pointing to shared queue managed by the multiprocessing.Manager() object. therefore you can’t pass normal multiprocessing.Queue() objects to Pool methods, because it … Read more

Array-Based vs List-Based Stacks and Queues

There are multiple different ways to implement queues and stacks with linked lists and arrays, and I’m not sure which ones you’re looking for. Before analyzing any of these structures, though, let’s review some important runtime considerations for the above data structures. In a singly-linked list with just a head pointer, the cost to prepend … Read more

A Queue that ensure uniqueness of the elements?

How about a LinkedHashSet? Its iterator preserves insertion order, but because it’s a Set, its elements are unique. As its documentation says, Note that insertion order is not affected if an element is re-inserted into the set. In order to efficiently remove elements from the head of this “queue”, go through its iterator: Iterator<?> i … Read more