Skip to main content

Questions tagged [multithreading]

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

Filter by
Sorted by
Tagged with
8 votes
1 answer
100 views

Movie Barcode Generator

Task I wrote a movie barcode generator in C++ using OpenCV. Self-described engineer, space lover and tea drinker Thomas Poulet defines a movie barcode as follows: A Movie Barcode is the color ...
Jay Gupta's user avatar
1 vote
0 answers
25 views

Java multithreading with Spring JPA

I have to improve a process that is currently sequential, and i wanna make it multi-thread. This process uses Spring JPA, with spring boot 2 and java 17. I would like to have a feedback on the ...
Fabio Piunti's user avatar
2 votes
2 answers
70 views

A thread-safe performant Money Transfer API in Java

This is a popular interview question. It is meant to be done within 30 minutes. The task is to implement a thread-safe performant Bank Account API that allows to transfer, deposit, withdraw and check ...
Sasha Shpota's user avatar
9 votes
2 answers
1k views

A TCP server which uses one thread to read while writing data with another thread

The TCP server in the code snippet below is designed to: Read data using one thread while writing data with another thread. Allow only one client to be connected at a time. Automatically close the ...
John's user avatar
  • 459
7 votes
2 answers
148 views

"Polite" internet connectivity check on separate thread

I wrote this class that checks for internet connectivity on a background thread. Targeting Python 3.10. It has two main design goals: Minimize the time get_state() ...
Jason C's user avatar
  • 451
0 votes
1 answer
73 views

Take photographs using simulated cameras that share a lock

I'm new to threading in Python. I want to use it to speed up taking images on my lab computer. I have the following dummy code: ...
AccidentalTaylorExpansion's user avatar
4 votes
1 answer
87 views

Multithreaded Alpha-beta pruning for playing Connect Four in Java

Intro (The entire repository is in GitHub.) This time, I have parallelized the famous Alpha-beta pruning algorithm. The idea is that the parallel algorithm descends in a game tree (at least) 2 levels ...
coderodde's user avatar
  • 28.9k
7 votes
2 answers
1k views

A thread-safe performant URL Shortener in Java

This is a popular interview question. It is meant to be done within 45 minutes. The task is to implement a thread-safe performant in-memory URL Shortener. My implementation is based on two maps that ...
Sasha Shpota's user avatar
1 vote
1 answer
82 views

Kotlin Compose authentication with Google and Facebook using a CircularProgressIndicator for UI loading

I had this problem: https://stackoverflow.com/questions/78528358/how-to-prevent-circularprogressindicator-from-freezing-during-authentication-in Now after fixing it, I want to make sure that this is ...
Cipri's user avatar
  • 11
3 votes
1 answer
61 views

how to launch multiple processes efficiently

I have a list of car models which I want to simulate by launching multiple instances of an external simulator executable. My application stores the current status of all the cars that are being ...
Harry's user avatar
  • 429
3 votes
1 answer
94 views

Multithread execution times are slow on Ubuntu and fast on Windows

I'm working on a project accelerating the execution of a Genetic Algorithm both on multiple cores and on a GPU. The algorithm is specifically suited for the solution of the Traveling Salesman Problem ...
Pietro Pianigiani's user avatar
7 votes
1 answer
273 views

Multithreading message queue system

For an application I'm developing, I need an system which allows a thread to submit messages to another thread. For this purpose I designed a message queue system with the following features. Any ...
Sam Coutteau's user avatar
1 vote
1 answer
43 views

Multi-threaded Error Handling Data Fetching Script

I've been working on a Python script that fetches student data from an API using multiple threads for concurrency. The script retrieves both student information and prospectus data and saves them to ...
K. Cinches's user avatar
0 votes
0 answers
43 views

Thread pooled bidirectional breadth-first search in Java for graphs with slow node expansion - part I/II: the algorithm

(This post has part II/II.) Intro This time, I have this GitHub repository. The idea is that if the graph node expansion is slow (for example, in the case where you ask a web server to return some ...
coderodde's user avatar
  • 28.9k
5 votes
3 answers
98 views

Time based cache for single element

The container should be thread safe and provide lazy load of data, and cache the data for set period of time. ...
trolkura's user avatar
  • 151
5 votes
2 answers
608 views

Generic multithreading solution for improving the performance of slow tasks

I'm currently in the process of replacing an archaic multithreading solution using some of the newer C++ standard library features now that our software has been updated to use C++20. Previously, most ...
Swepps's user avatar
  • 53
1 vote
0 answers
88 views

Feedback on a ThrottledInvoker class

State in a Fluxor app can be updated many times per second, with each change triggering a render in Blazor. I wanted to write a class that would throttle these notifications so they don't occur more ...
Peter Morris's user avatar
1 vote
1 answer
76 views

Multiple Producer and Multiple Consumer Implementation Using Locks and Semaphore

This solution has a total of four classes. Main.java: Class with main method. Execution starts here. ...
vvs14's user avatar
  • 111
3 votes
1 answer
136 views

C++ inline minimalist thread pool

This is a "minimal thread pool" I came up with to compare with a colleague's approach using Rust's Rayon's par_bridge() to automatically parallelize ...
Wasfi JAOUAD's user avatar
3 votes
1 answer
241 views

Logging in a different thread using circular buffer C++

What it does The code creates a logger class which instantiates a circular buffer at construction and uses producer-consumer style approach using condition_variable to log and print the messages to ...
wwite's user avatar
  • 33
2 votes
1 answer
71 views

Multithreaded natural language text parser (Rev.2)

This is the second iteration of the Multithreaded natural language text parser code review. Special thanks goes to G. Sliepen who conducted the first review. Before reading this post, please read the ...
Damir Tenishev's user avatar
2 votes
1 answer
109 views

Multithreaded natural language text parser

Could you please conduct code review for the code below and suggest some improvements? Functional specification Implement a multithreading parser based on existing natural language tokenizer. Parser ...
Damir Tenishev's user avatar
1 vote
2 answers
90 views

Static media gallery generator with python 3.12

The main concern is the hard requirement for python3.12 since I couldn't find a clean replacement for pathlib.Path.relative_to(root, walk_up=True) in earlier ...
ccpizza's user avatar
  • 157
1 vote
0 answers
62 views

Lockless synchronized access to ConditionalWeakTable

I am inexperienced with writing multithreaded applications, and I am trying to wrap a ConditionalWeakTable (CWT) for use as a generalized container type. I'm aware ...
monkey0506's user avatar
0 votes
1 answer
99 views

decorator for an Executor that allows to get a List of running tasks

As stated in the javadoc below, this is intended for monitoring and debugging. I've found it especially useful for figuring out which tasks got stuck and prevented clean terminations of my ...
morgwai's user avatar
  • 401
3 votes
1 answer
101 views

simple multi-threaded TCP chatroom in Java

I'm fairly new at coding and looking to improve. Down below is all of my files for a TCP chatroom with a GUI in java. This is my first networking project so I'm sure it has many problems and does not ...
James Cowsert's user avatar
2 votes
2 answers
218 views

Circular Queue Producer Consumer with Mutex and Condition Variable vs. Sempahore

How can I optimize the performance of the code below? Destruction of the condition variable at the end of main blocks, not sure why this behavior is occurring. Is it possible to remove some of the ...
Darnoc Eloc's user avatar
2 votes
1 answer
839 views

Efficient parallelization of small tasks

Problem statement: Consider a scenario where a vector of very small tasks, each encapsulated within a class 'Task' with a thread-safe method Task::process(), needs to be efficiently processed in ...
Shakti Malik's user avatar
7 votes
1 answer
249 views

Differential Evolution

I have a PR implementing differential evolution. I'm a bit concerned about the implementation and would like some feedback: The class could be a free function. However, there are so many parameters, ...
user14717's user avatar
  • 775
1 vote
2 answers
403 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 ...
lonix's user avatar
  • 143
3 votes
1 answer
447 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 ...
EricFlorentNoube's user avatar
1 vote
0 answers
87 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 ...
Amir Suleymanov's user avatar
4 votes
2 answers
386 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....
Andrey Epifantsev's user avatar
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 ...
P4PL4's user avatar
  • 111
3 votes
1 answer
112 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. ...
Mr. Orange's user avatar
1 vote
0 answers
86 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 ...
Michael Lundie's user avatar
0 votes
1 answer
130 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 ...
wallyyopp's user avatar
3 votes
2 answers
190 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 ...
Andrey Epifantsev's user avatar
0 votes
1 answer
195 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 ...
Ravi Kumar's user avatar
2 votes
2 answers
138 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 ...
Bula's user avatar
  • 369
2 votes
0 answers
23 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 ...
cpicanco's user avatar
  • 499
4 votes
2 answers
89 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 ...
Ders's user avatar
  • 43
1 vote
0 answers
155 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 ...
PilotGuy's user avatar
5 votes
1 answer
474 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 ...
mascai's user avatar
  • 379
4 votes
1 answer
126 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" ...
Bula's user avatar
  • 369
1 vote
0 answers
44 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 ...
dimo414's user avatar
  • 417
2 votes
1 answer
809 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 ...
Szyszka947's user avatar
2 votes
1 answer
111 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): ...
Oersted's user avatar
  • 337
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 ...
Oersted's user avatar
  • 337
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 ...
larssonmartin's user avatar

1
2 3 4 5
33