Questions tagged [multithreading]

Use this tag when the program performs its work using multiple concurrent threads of execution.

Filter by
Sorted by
Tagged with
1 vote
2 answers
73 views

Stopping a running thread

I am trying to stop an executing runnable instance after the run method has been called. I have come up with the below approach ...
1 vote
2 answers
124 views

Thread-safe int wrapper in c#

My system is a .NET Core 7 console app, which starts some background threads. I need to pass some int values (counters, etc.) between the main and background ...
3 votes
1 answer
94 views

C++ implementation of a concurrent queue and of a thread pool

I am working on an implementation of a concurrent_queue<T> and pf a ThreadPool, see beneath. The objectives are CPU ...
1 vote
0 answers
35 views

Telegram bot computing a heavy I/O task

Introduction I have a telegram bot based on aiogram framework. It does GPU intensive computations locally then user makes a request and outputs a text file after ...
4 votes
2 answers
341 views

Class for locking shared disk directory

I'm writing an application to sync files between two directories. In order to prevent simultaneous access to the shared directory from several computers, I implemented blocking of the shared directory....
11 votes
4 answers
2k views

Simple Key Value Database using C

I was recently doing an assignment for a job interview, which asked to create a simple key value database with 4 command line operations: create key value: Adds a key value pair/updates an existing ...
0 votes
1 answer
131 views

Training a Reinforcement Learning algorithm

Problem: I'm trying to reduce the computation time and optimize specific functions of a Reinforcement Learning algorithm in the training phase and observed that one block of code takes too much ...
3 votes
1 answer
67 views

Multi producer/consumer lock-free queue

I would be grateful if you could review my code for a multi producer/consumer lock-free queue in C++. I am mainly after performance improvements, but all input is welcome. ...
1 vote
0 answers
38 views

Tkinter threadpool with callback implementation - alternative approach feedback

This is an attempt to create a usable alternative to the "normal" method of implementing concurrency with tkinter. The "normal" method seems to be by pro-actively polling a result ...
7 votes
1 answer
245 views

Python asyncio multithread wrapper

For my application, I needed a lightweight way to launch multiple tasks and monitor their completion in a main loop periodically or use callbacks. The main loop is going to be busy most of the time ...
3 votes
1 answer
275 views

Golang function that reads S3 files and populates maps with strings as keys

I have a below read function which is called by multiple go routines to read s3 files and it populates two concurrent map as ...
0 votes
1 answer
171 views

Why is this not considered better way than Async Await

After so many searches and back-and-forth attempts, I have developed an TCP Server to listen to the network stream and it is working fine. So kindly review the code, and please let me know if this ...
0 votes
1 answer
27 views

Handling multiple socket communication in Python Client-Server application [closed]

I'm developing a client-server game application in Python. Here's the scenario: Clients connect to the server and register. After registration, all clients see a main menu. One client can initiate a ...
3 votes
2 answers
165 views

Multithreaded disk scan

I'm writing an application to compare and sync folders on a disks. Scanning the contents of folders is performed in separate threads. I wrote a class to manage scan threads. The main application class ...
0 votes
2 answers
108 views

Web scraping spider

I'm currently working on my first web scraping project and I need to scrape a lot of websites. With my current code it takes more than a day but for my project I need to scan the same websites every 5 ...
2 votes
2 answers
121 views

Thread-safe coordinate holder

I have been given a task to create a thread-safe RobotCluster class. The idea is that there's a set of robots operating on multiple threads and they each submit the ...
2 votes
0 answers
15 views

Recording/Playback thread device in Object Pascal

I have developed an audio recording and playback base device in Free Pascal. This device is built on Free Pascal's TThread class and utilizes the low-level audio ...
0 votes
1 answer
139 views

Lock-free implementation of getAndUpdate() using atomic CAS (Compare-And-Swap) operation

We have the following class written in Kotlin Native with the new Memory Manager (which doesn't require to freeze objects): ...
4 votes
2 answers
79 views

C++ Neuron Spike Raster Deserializer

Please help me establish a solid foundation for this computational neuroscience project. I'd like to make sure I'm moving forward with something reasonable before I begin tackling the more complex ...
1 vote
0 answers
67 views

Optimizing tokio and pcap Operations in Rust for Max Throughput

Background I'm mostly a c# and python programmer and am slowly learning Rust. I'm not sure if that is contributing to incorrect concepts as to how threading and io work in Rust, but that's what I'm ...
5 votes
1 answer
399 views

Print abcabc... in three threads

I want to implement the following case Input - integer number n Start 3 threads. The first thread prints 'a', the second prints 'b', the third prints 'c', then the ...
4 votes
1 answer
108 views

Packet generation and consumption

I have the following simplification of a program which consists of 2 threads. One thread pushes packets to the back of a deque while another waits for user input before performing a "heavy" ...
1 vote
0 answers
36 views

Handling a subprocess' output in background threads and accepting user-provided sinks for the output

I have a PR swapping from Command::output() to a custom implementation using threads to handle the subprocess' stdout/stderr while the program is running, instead ...
0 votes
0 answers
105 views

For loop vs If statement using conditional variable

I'm extending the sync.Pool type by limiting the amount of objects that can reside outside the pool. To achieve this I'm using ...
3 votes
1 answer
126 views

A mutex that can detect certain types of programming error

This mutex prevents concurrent access to a target resource. One key requirement is the ability to be acquired in a (scheduler) thread and released in a different (worker) thread. Unfortunately this ...
0 votes
1 answer
125 views

C++ slim condition notifier

When writing multi-threading code, one often need the thread to wait for some condition being met. A naive approach would look like this: ...
2 votes
1 answer
349 views

Parallel handling db queries is very slow in C#

I have SignalR app that publishes sent messages to Redis. My console app subscribe to channel where these messages are sent, deserializes it and saves in database. Problem is with handling these ...
2 votes
1 answer
124 views

DFS Maze Solver

I am new to Rust Programming so I decided to implement a Maze Solver using DFS. I was wondering if there is any way to optimize this code further ...
2 votes
1 answer
100 views

C++: algorithm that uses fixed-size buffer of data that are produced in stream, faster than the algorithm speed; modified version

This is a, I hope, an improved version of this code, limiting atomic usage (following @GSliepen, @G.Sliepen advice) (NB I'm limited to, at most C++17): ...
7 votes
1 answer
1k views

C++: algorithm that uses fixed-size buffer of data that are produced in stream, faster than the algorithm speed

I try to implement this scenario with a producer/consumer multithread pattern and I'd like to optimize synchronization and memory model directive used. This code originates from a SO question and its ...
5 votes
3 answers
2k views

An exercise in Data Oriented Design & Multi Threading in C++

Been working in games development professionally now for about ~5 years, but have only been doing OOP & haven't worked with multi threading before as I'm mostly a gameplay programmer, I've also ...
5 votes
2 answers
127 views

Get files downloaded asynchronously after double clicking on list item (C++)

The problem I am trying to solve as an exercise is as follows: I have a UI running in the main thread, specifically a list view with many items. Each item represents a file that the user can download....
2 votes
1 answer
70 views

Single worker, multiple async callers in different threads

My use case is this: There is a long running process that I want to ensure is only ever running at most only a single time. Multiple consumers from different threads may wait on the calculation. If ...
3 votes
1 answer
84 views

Parallel semi-sequential bottom-up tree traversal algorithm

I'm trying to traverse a tree-like structure from the bottom-up, and in parallel. Due to some other constraints I also have to allow for thread counts that may be lower than the width of a given set ...
1 vote
1 answer
151 views

Multithreaded O_DIRECT file read-and-process program

Here is my code. It reads a file and returns the sum of all the bytes in the file: ...
1 vote
0 answers
60 views

A parallel MSD radix sort in Java for integer keys

I have this repository: https://github.com/coderodde/ParallelRadixSort.java/tree/main It contains a parallel MSD radix sort presented below: ...
0 votes
0 answers
38 views

Trait to extend iterators with parallelized mapping function

Working on a project of mine, I wanted to parallelize mapping operations on an input stream. I found pariter on crates.io but it did not fit my needs, because its generic's bounds require the iterator ...
3 votes
2 answers
543 views

New York Times' Digits Game Solver

I wrote an algorithm to solve the New York Times' Puzzle: Digits. You could play the game here. The rules of the game are as follow: You were given 6 numbers and you could use simple operations (plus, ...
1 vote
1 answer
99 views

Rate-limited thread scheduler in Java

Background: I'm planning to call different endpoints of a website's API quickly, but the usage policy implies that I may only make five calls in a second. I can't rely on the calls taking 200 ms on ...
2 votes
1 answer
115 views

Parallelization of the tick function in a Game of Life simulation using Rust and Python (+ NumPy)

I've been writing a small Rust module recently with the sole purpose of speeding up my Python program, which is a Conway's Game of Life simulation. The function written in Rust is called from Python ...
4 votes
1 answer
492 views

Threadsafe Non-Overlapping Timer

I was working on a project recently, where I needed to process some tasks periodically, but the execution of those tasks could not overlap with one another. ...
1 vote
1 answer
109 views

C++ Dynamic Balancer on a Threadpool

I have a Balancer Class in my project which should dynamically increases/decreases the amount of Worker Thread based on the current amount of Messages which are ...
4 votes
2 answers
1k views

Multi-threading Class in C++

I wrote a C++ class which can take a vector of functions and their respective arguments and execute them in parallel and return a vector of results from its respective functions. ...
2 votes
2 answers
259 views

Code for asynchronous data stream processing with multistage pipelines

I am trying to write some code for processing streams of asynchronous data from multiple sources (Producer Nodes), process them ...
4 votes
2 answers
221 views

Multithreaded Conway's Game of Life implementation written in C and Java using JNI

I had some multithreading C programming experience from school last year but I wanted a bit more so I tried to program a Conway's Game of Life implementation from scratch. Code is mainly written in C ...
2 votes
1 answer
241 views

Producer/Consumer Multi-Thread implementation - Is the solution correct?

I recently faced this following question in a Java coding round, needless to say I did not get a callback. So I want to know where I am going wrong in my solution and also what can be done to improve ...
6 votes
1 answer
385 views

Synchonizing queue with mutex

I am trying to syncronize the queue between threads using mutex. I have 2 mil random integers in input.txt file. Main thread reads integers then puts them in queue. Other threads are simultaneously ...
5 votes
3 answers
2k views

Least Recently Used Cache with TTL

I found this problem in a book and found it interesting. wrote this class to implement a Least Recently Used Cache with TTL. Goal - LRU cache with TTL Multithreaded. Functions: Get(key), Put(key,...
4 votes
1 answer
321 views

Multithreading a shortest path algorithm

I would like to modify my shortest path finding code to use multithreading and improve its performance. The algorithm must be able to work with negative weights, and as a result, we cannot use ...
6 votes
2 answers
1k views

C++ Thread Pool Implementation using Lock Free Queue

Topic: C++ Implementation of Lock-Free Queue and ThreadPool classes In a project I'm currently working on, I need the implementation of ThreadPool along with a thread-safe queue. I've tried ...

1
2 3 4 5
32