Skip to main content

Questions tagged [multithreading]

Multi-threading related questions including technique, structure, and safety issues.

Filter by
Sorted by
Tagged with
4 votes
2 answers
160 views

I am trying to automate an old GUI tool which requires filling in some data from a CSV and selecting appropriate tree item values based on it. I need to do this in multiple instances of the ...
Yashbhatt's user avatar
  • 149
2 votes
4 answers
203 views

I'm developing a multithreaded game server (C/TCP). I need to send a list of 50-100 available games to a console client. Option A: Send 50-100 separate messages, using send() for every single ...
dok's user avatar
  • 311
1 vote
1 answer
111 views

Situation: Order Handling in OMS System: In my OMS system, orders are pushed from an online platform with a unique orderId. Since the orderId is generated by the online platform, I cannot make it auto-...
Help out's user avatar
3 votes
3 answers
695 views

What are things that newer CPU can do to speed up single thread execution? multiple registers? (can compilers always benefit from it?) SIMD? (do compilers use SIMD without code annotation?) does a ...
jokoon's user avatar
  • 2,280
1 vote
1 answer
413 views

Reading the Proactor pattern paper, specifically this part: I/O Completion Ports in Windows NT: The Windows NT operating system implements the Proactor pattern. Various Asynchronous Operations such ...
codefast's user avatar
  • 179
4 votes
10 answers
5k views

I am trying to understand the difference between CPU Bound vs IO Bound process. ChatGPT suggested that multi-threading/parallel processing can help a CPU bound process; However, I think that having ...
Sahil's user avatar
  • 199
0 votes
1 answer
261 views

As my next spare-time project, I'm considering writing a suite of compatibility header and associated library, that eases the transition from Single Unix Specification v4 to v5 and C11/C17 to C2X. C++ ...
DannyNiu's user avatar
  • 374
0 votes
1 answer
610 views

Background: I am working in a Java environment using Spring Boot, where I often encounter scenarios where global variable state management is critical, especially within singleton services. I have ...
procrastinator1771's user avatar
10 votes
5 answers
4k views

I'm writing a .NET library which exposes certain public APIs. Currently, I have not enforced thread safety in my library for following reasons apparent to me: locks (Monitor.Enter and Monitor.Exit) ...
Zombies are Real's user avatar
0 votes
1 answer
150 views

As I understand it, the join() method merge/composes/combines the results from all subtasks. A simple example I saw was summing the numbers from 1 to N and the subtasks would simply sum a range of ...
releseabe's user avatar
  • 539
0 votes
2 answers
1k views

The Rust programming language offers a Arc atomic reference counting generic type for use in multi-threading environment, since Rc is optimized for performance in single-threaded applications, and ...
DannyNiu's user avatar
  • 374
1 vote
1 answer
173 views

I'm trying to come up with a peace of code that would fetch centralised cache shared across multiple threads/app instances. Callers might come in swarms. The data is a large set, reads during ...
FoxMulder's user avatar
1 vote
2 answers
491 views

I am writing a little C library for the Raspberry Pi for controlling 433MHz transmitters/receivers. While receiving data the whole application would block, so I decided to put this code into a ...
blackdog's user avatar
1 vote
2 answers
369 views

Over and over I am faced with a similar problem: I have to perform two actions that are mostly unrelated, except that they need to share a mutex lock, at least for a moment. For example: void action() ...
CygnusX1's user avatar
  • 257
0 votes
5 answers
1k views

First of all, let me clarify the terms in order to avoid any possible misunderstandings. Language is considered to be compiled when a program written in it's source code cannot be run directly without ...
tnsaturday's user avatar
1 vote
1 answer
1k views

I am working on a simple client server program in C in which multiple clients will be connected to a single server. Clients will submit operations/actions to the server and the server will process ...
nick2225's user avatar
  • 157
0 votes
1 answer
1k views

Trying to understand and compare synchronization primitives, like std::future/std::promise, std::barrier and std::conditional_variable - developing an intuition for which one to use when exactly. I ...
xyf's user avatar
  • 109
1 vote
4 answers
924 views

I am an inexperienced developer fresh out of college. I was handed a Windows Forms Application to work on. The application previously relied on system time. They wanted me to make it so that we could ...
mpAppProg's user avatar
0 votes
1 answer
128 views

Can NIC handle(send/receive) multiple packets at once? For example, 2 asynchronous tasks request 2 different things from a database. Are those 2 requests sent simultaneously by NIC? Also, are the ...
DimitrijeCiric's user avatar
0 votes
3 answers
2k views

I'm building an HTTP server in C using epoll and pthread. The idea is to have an event loop in the main thread monitoring file descriptor and a thread pool to handle computationally-expensive ...
Richard H. Nguyen's user avatar
1 vote
2 answers
1k views

What would the appropriate design pattern to avoid deadlock when several functions use the same mutex ? It is quite easy to forget what method uses the lock and so it happens that you call a function ...
cylon86's user avatar
  • 111
4 votes
2 answers
1k views

I've been learning about threads and processes and I understand that threads allow you to write concurrent code: where executing threads switch very quickly from one to another, giving the impression ...
Avantgarde's user avatar
0 votes
2 answers
4k views

I have a multi-threaded application. There is 1 thread that produces a resource and puts it into a queue and many (not constant amount) consumer-threads that get the resources from the queue. When ...
g00dds's user avatar
  • 111
1 vote
4 answers
5k views

Background: We're providing an API that provides information about all users within a given group. Our API is a high level facade over another low-level REST API. To gather those information we first ...
das Keks's user avatar
  • 213
4 votes
3 answers
2k views

My task is, I think, pretty interesting, if a bit unusual. Any number of threads can call function f(). They add some data to a buffer and begin waiting (the function is blocking). Eventually some ...
Violet Giraffe's user avatar
20 votes
8 answers
6k views

Multi threading could cause a racing condition if two threads are accessing the same memory slot, but why is that? From a HW point of view, if the two cores are designed the same, internal pipelines ...
Dan's user avatar
  • 319
0 votes
2 answers
2k views

What are the most efficient and low-latency approaches for sharing data between threads in a C++ system, and why? My primary concern is minimizing latency and maximizing performance, as I have two ...
dogma sucks's user avatar
7 votes
1 answer
552 views

I am reading through "Clean Architecture: A Craftsman's Guide to Software Structure and Design" and it says that: All race conditions, deadlock conditions, and concurrent update problems are ...
Quantum Guy 123's user avatar
0 votes
1 answer
171 views

I'm not sure if my answers to the following exercise is correct: Suppose the program is run with two threads. Further suppose that the following sequence of events occurs: Time Thread 0 ...
Lilian Shi's user avatar
0 votes
1 answer
330 views

I have a job system that has two different types of dependencies per-job: Jobs can rely on other jobs to be completed first, but this is optional Jobs have read/write dependencies (shared/exclusive) ...
HateDread's user avatar
0 votes
0 answers
1k views

I want to understand how does Spring Boot and Postgresql DB handle the concurrent requests for updating a value in DB. Consider this example of facebook likes, if there are multiple instances of ...
Spring boot progammer's user avatar
3 votes
3 answers
5k views

I have never used atomic operations, and remain largely ignorant of how to utilize them. And yet, I often come across objects like this when peering into Qt's backend: https://doc.qt.io/qt-6/...
Anon's user avatar
  • 3,649
1 vote
0 answers
299 views

Backstory Probably a stupid question, but I just have a sneaking suspicion that "asynchronous" is the wrong terminology to us for naming my template function here: template <class T> ...
Anon's user avatar
  • 3,649
0 votes
1 answer
350 views

When designing my simulator, I have gotten stuck on 2 main design choices. The simulator can be described as having X number of nodes (between 50 - 2000) that each need to independently do some ...
Nabiel Kandiel's user avatar
-1 votes
2 answers
124 views

Since I don't have much knowledge of multi-threaded design and English is not my native language, I don't know how to exactly describe my problem. Let's say I have a mini-program in school, which has ...
Justin's user avatar
  • 3
0 votes
1 answer
279 views

I have a program that accepts computer names and then will perform CIM session tasks. The computer names are passed in from the user input and separated by "," (ex: program.exe -computers ...
James's user avatar
  • 11
33 votes
7 answers
8k views

Sometimes computers stutter a bit when they're working hard, to the point where the mouse location freezes for a fraction of a second, or stutters intermittently for a few seconds. This sometimes ...
Paul Calcraft's user avatar
-1 votes
2 answers
295 views

Background: I'm coding an app, the core idea is simple - I can choose a 'Task' (consists of name, code to perform aka Runnable, progress) through GUI, start it, stop it, start all 'Task's and stop all ...
Wiktor's user avatar
  • 33
0 votes
2 answers
395 views

I have a technical application that interacts with different hardware components: measurement devices, sensors, custom hardware. These use dedicated interfaces like USB, serial ports, TCP/IP ...
FourtyTwo's user avatar
  • 119
1 vote
1 answer
920 views

I have a class like this. (My actual class is different. I am using this to explain the problem). This class instance is shared between 2 threads. However those 2 threads (thread1 and thread2), call ...
RamPrakash's user avatar
-2 votes
1 answer
217 views

I've bought a samsung galaxy s21 ultra about a year ago. Today i was looking at the specs again and i noticed that the Samsung Exynos 2100 processor consists out of 1 single CPU core of 2.9 GHz, three ...
Maurice's user avatar
  • 133
0 votes
0 answers
88 views

Here is the question. On a 2.2 GHz processor with 6 physical threads and 6 hyperthreads, I see performance on the order of 3-10s for a particular job involving OpenCV. I do not specify that the ...
Chris's user avatar
  • 109
-1 votes
2 answers
1k views

Suppose I have two threads, A and B. A is waiting for input, while B is waiting to be executed. All other CPU cores are busy with CPU-bound tasks. What will happen to A?
moonman239's user avatar
  • 2,063
4 votes
1 answer
2k views

I have a classical one producer - multiple consumers queue, each item can be processed independently. On rare occasions (<1%) there can be multiple queue items related to the same object the ...
Dmitry Streblechenko's user avatar
0 votes
3 answers
628 views

We have following class: class ProcessStore { ConcurrentDictionary<int, MyDisposableClass> _processes = new(); bool _disposed; void Store(int Id) { if(_disposed) { throw; } ...
Shadow's user avatar
  • 361
3 votes
1 answer
189 views

I have 1-20 agents that issue requests over time with roughly ~50 in total in flight at any given time. Many of these requests are identical. The tasks are idempotent, but if two identical requests ...
Unknown1987's user avatar
0 votes
1 answer
2k views

So, I have the following two functions in THE SAME class: void start() { ... m_pRunnable = createRunnable( [spDiskManager = m_spDiskManager, path = m_path, &success =...
Wballer3's user avatar
0 votes
1 answer
3k views

I have a C#-based system that works relatively well. It reads data from kafka, processes the data and then writes it out to MSSQL. The kafka topic has been partitioned into 10 partitions - and after 2 ...
Mulciber Coder's user avatar
10 votes
8 answers
4k views

My question will be mostly about Linux and contemporary X86 hardware. Clarifying the terms async event based programming: spawning fixed amount of threads and using some user space scheduling ...
Incomputable's user avatar
0 votes
3 answers
233 views

In C#, how do I handle critical section with two different "rights of way"? Theoretical use case: imagine a swimming pool (the resource). Many individual swimmers (worker threads A, B, C, ...
Yann's user avatar
  • 119

1
2 3 4 5
14