Latest Questions tagged Concurrency

Browse all latest questions tagged Concurrency

131
Votes
Published 19 Sep, 2022
Java - Java 8 Unsafe: xxxFence() instructions

In Java 8 three memory barrier instructions were added to Unsafe class (source): /** * Ensures lack of reordering of loads before the fence * with loads or stores after the fence. */ void loadFence...

60
Votes
Published 29 Oct, 2022
Java - Which data structure to use to store millions of objects in multithreading environment ( Scalability and performace )?

My requirement is like : I want to perform frequent operation on millions of objects in multi-threaded environment with concurrency and scalability keeping in mind, I need best data structure suitable...

184
Votes
Published 22 Aug, 2022
Python - multiprocessing.Pool: When to use apply, apply_async or map?

I have not seen clear examples with use-cases for Pool.apply, Pool.apply_async and Pool.map. I am mainly using Pool.map; what are the advantages of others?

35
Votes
Published 31 Aug, 2022
Python - concurrent.futures.ProcessPoolExecutor vs multiprocessing.pool.Pool

Please explain to me what is the difference between these two classes? concurrent.futures.ProcessPoolExecutor multiprocessing.pool.Pool I noticed multiprocessing module existed in Python 2. But fu...

112
Votes
Published 15 Sep, 2022
Java - How does ConcurrentHashMap work internally?

I was reading the official Oracle documentation about Concurrency in Java and I was wondering what could be the difference between a Collection returned by public static <T> Collection<T>...

118
Votes
Published 15 Sep, 2022
Java - Why is creating a Thread said to be expensive?

The Java tutorials say that creating a Thread is expensive. But why exactly is it expensive? What exactly is happening when a Java Thread is created that makes its creation expensive? I'm taking the s...

99
Votes
Published 07 Sep, 2022
Java - Reentrantlock - Why do we need to acquire a lock multiple times?

I have recently been learning multithreading concepts in java. I have a few doubts which didn't resolve by looking up the relevant threads on StackOverflow. I couldn't find satisfactory answers for my...

329
Votes
Published 06 Sep, 2022
Java - Volatile boolean vs AtomicBoolean

What does AtomicBoolean do that a volatile boolean cannot achieve?

29
Votes
Published 24 Aug, 2022
Python - `DummyExecutor` for Python's `futures`

Python's futures package allows us to enjoy ThreadPoolExecutor and ProcessPoolExecutor for doing tasks in parallel. However, for debugging it is sometimes useful to temporarily replace the true paral...

48
Votes
Published 19 Sep, 2022
Java - Adding a Pool of Threads in a RxJava Flow

I was wondering if I can use the RxJava library in order to add some concurrency in the following use-case: Fetch sequentially a String column from an existing ResultSet with a custom Observable (so...

40
Votes
Published 12 Aug, 2022
Python - mysql python concurrent access on same table column

I've explored a few solutions without much success. I have two python processes (created with Popen from subprocess) and one mysql table (called persone) containing one row with two columns: Age:0, i...

277
Votes
Published 05 Sep, 2022
Java - Synchronization vs Lock

java.util.concurrent API provides a class called as Lock, which would basically serialize the control in order to access the critical resource. It gives method such as park() and unpark(). We can d...

79
Votes
Published 03 Sep, 2022
Java - is DatagramSocket.send thread safe?

I'm planning to use an instance of DatagramSocket and call its send method from different threads... to send UDP packets to different clients. Is the method thread safe i.e. calling this method from d...

67
Votes
Published 06 May, 2022
Python - How to limit concurrency with Python asyncio?

Let's assume we have a bunch of links to download and each of the link may take a different amount of time to download. And I'm allowed to download using utmost 3 connections only. Now, I want to ensu...

105
Votes
Published 08 Sep, 2022
Java - When is CopyOnWriteArraySet useful to achieve thread-safe HashSet?

In Java, there is thread-safe version HashMap named ConcurrentHashMap and thread-safe version TreeMap named ConcurrentSkipListMap, but there is no ConcurrentHashSet for HashSet. Instead, there are us...