Questions tagged [multithreading]

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

Filter by
Sorted by
Tagged with
6 votes
2 answers
403 views

c++ multithreaded message broadcaster with link lifetime management v3

note: This is v3 of code that was previously reviewed. I have written a class that handles listeners registering callbacks to receive messages. Link lifetime is managed (or is it? See below). Code is ...
Diederick C. Niehorster's user avatar
4 votes
1 answer
2k views

Use a static field for cache an authentication token in .NET API

I have a .NET 6 web API that does some requests to another third party API, this API has a token that expires after a few hours, so I want to cache this token and reuse in the requests. Here how I ...
Vanderlei Morais's user avatar
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 ...
Raffaele's user avatar
  • 131
2 votes
1 answer
117 views

Multithreaded segmented Sieve of Eratosthenes

I am fairly new to Rust and thought a good way to practice would be to write a multithreaded segmented Sieve of Eratosthenes. It performs ok (searches ten-billion numbers in about 11 seconds on my ...
knots427's user avatar
2 votes
1 answer
60 views

Force acquiring R/W lock

I am trying to build an abstraction that forces lock acquisition before data can be accessed. This seems to work, but please tell me if what I am doing horribly wrong, and what I could improve. I am ...
optimistic's user avatar
1 vote
2 answers
93 views

multithreading LRUcache in C++

I want to implement a multithreading LRU cache in C++. And here is the code. Can you tell me what should I do to make it more multithreading? ...
Jacob's user avatar
  • 111
3 votes
2 answers
105 views

Fast portable, parallel MSD radix sort for unsigned keys in C89

Now I have this portable, parallel MSD radix sort for unsigned keys. It exhibits linear speedup on small values of \$P\$ and has a running time of $$ \Theta(N/P + P)...
coderodde's user avatar
  • 27k
4 votes
2 answers
805 views

Traffic simulation GUI: an exercise in concurrent programming using threads

To avoid a code dump I have removed most of the code and left the first few lines of constructors and methods and anything relevant. Full code at the bottom. The purpose of this code is to use threads ...
Corey Hodges's user avatar
1 vote
1 answer
114 views

Timeit multithreading/multiprocessing C++

Given a Timeit method which runs for n times the provided function, which approach between multithreading and multiprocessing should be better to speed up the execution of all iterations and avoid the ...
BloomShell's user avatar
2 votes
2 answers
242 views

the multi-threading of adding all the values from a random generated vector

I currently am creating a vector and fill it with random values( for this case the random values will be 1) once the vector is created i want to calculate the total sum which should be 100000000, I am ...
Keanu.c's user avatar
  • 21
0 votes
0 answers
182 views

Design a thread-safe Hit Counter

I have designed a Hit Counter which can conveniently be used to design a Rate Limiter Original question: https://leetcode.com/problems/design-hit-counter/ To make it thread safe, I used lock statement....
Daniel B's user avatar
  • 136
4 votes
1 answer
222 views

Multithreaded MVC game engine

This is an attempt at a multithreaded model-view-controller based engine for 2d console games (board games, roguelikes that sort of thing.) The code below will provide a fully working example but is ...
Jaldhar's user avatar
  • 409
2 votes
1 answer
152 views

Card game simulations, with a multithreaded version slower than the single-threaded one

I'm new to rust and I'm trying to build a card game simulation to find all of the best actions with all possible hands. This requires a lot of simulations and my first 3 million are already taking a ...
PaulEliaz's user avatar
2 votes
1 answer
250 views

Thread scheduler in C

I have made a simple round robin scheduler that switches between threads in ptable array. Currently it's only for 1 CPU, so there are no locks at the moment. But ...
runningupthatroad's user avatar
4 votes
1 answer
2k views

Timer thread implementation

I've implemented a timer thread whose job is to call functions at a certain interval. The functions may be called multiple times if their interval > 0 millisec otherwise only one time. Even if the ...
Daya Shanker Prasad's user avatar
2 votes
1 answer
92 views

Monitoring webpages to be notified

I have been writing a monitoring script where I check for whenever there is changes on a webpage. When a change has happend I want to be notified by printing out that there is a difference. I have ...
PythonNewbie's user avatar
2 votes
1 answer
141 views

Priority Job/Task Queue for Linux (sockets and multithreading)

Preface Please review my implementation of a job queue for linux/unix systems. This is my first time coding in C, although I have quite some experience in C++. I know this is a moderate amount of loc, ...
infinitezero's user avatar
3 votes
2 answers
195 views

Thread-safe cached compiled Regex

I have a use case where I want to keep a pre-compiled regex, cached, for performance reasons, but the regex pattern also needs to be updated infrequently. Instances of CachedRegexFilter class will be ...
Dexter's user avatar
  • 415
2 votes
1 answer
95 views

Compare between two dictionaries

Hello beautiful people! I have currently worked on a small script that I would of course continue to work with whenever I get a good feedback from the best code reviewer in here <3 - I have worked ...
PythonNewbie's user avatar
4 votes
2 answers
142 views

Simple multi-threading setup for tile rendering (C++)

I am writing a small framework that I intend to build upon in the future. I am also using this framework to teach people how to support multi-threading in 3D rendering, and thus wanted to be sure I ...
M. Saintourens's user avatar
1 vote
1 answer
149 views

A C++ Job Manager Class (Rev 1)

This is a revised version of the JobManager class originally posted here. The revisions made were centered around: Encapsulating the ...
big54mac's user avatar
4 votes
1 answer
118 views

Task executor thread pool

Despite my experience with Java, I am not well-versed with concurrency. I wrote this thread pool that has a queue of tasks. Please ignore any signature choices, such as overuse of ...
Oliver's user avatar
  • 93
3 votes
2 answers
116 views

Ball movement within an area

I was asked to write a code in C++ using threads, in which I have to have two limits and 4 characters. Characters can go inside the area limited at the same time when they approach from opposite sides....
Sean's user avatar
  • 31
1 vote
1 answer
232 views

NTP client displaying reference, originate, receive and transmit timestamps periodically with graceful shutdown in C#

based on this stackoverflow topic: https://stackoverflow.com/a/12150289/15270760 I have decided to create a simple NTP client displaying difference between NTP server response and DateTime.Now called ...
Artur's user avatar
  • 169
1 vote
1 answer
465 views

Multithreaded observer pattern in Rust

I often want to program in an event driven way, but classic implementations of the observer pattern often pose an ownership challenge, and they only get more difficult once multiple threads are ...
Blue7's user avatar
  • 373
3 votes
2 answers
1k views

Multithreaded tcp server accepting two clients with task factory and graceful shutdown

as an exercise from multithreading and networking I have decided to create my own implementation of TCP server accepting connections from two clients (which is I think a pretty common case e.g. chess ...
Artur's user avatar
  • 169
1 vote
0 answers
2k views

Implementation of Concurrent List in .NET

I would appreciate review of this implementation of the concurrent list that is, to my knowledge, currently missing in .NET Core. Requirements Thread safe Lock free Ordered Supports get and set by ...
Anonymous's user avatar
  • 111
2 votes
1 answer
2k views

C++20 Multi-queue Thread Pool with Work Stealing

This is a follow up to my previous post which also follows up on my first post regarding my thread pool implementation. I have since made some further changes and attempted to improve performance with ...
Developer Paul's user avatar
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 ...
AndyP's user avatar
  • 229
4 votes
2 answers
329 views

Multi-threaded Mandelbrot set generator slower than single thread

I am new to parallel programming. I have been playing around with multi-threading and for some reason, multi-threading the Mandelbrot set is slower than running a single thread. I have been trying to ...
Niralana's user avatar
1 vote
1 answer
451 views

Thread in a Spring app that watches a directory for new files

Before showing-off the code, here is a bit of an explanation. I have a Spring component that spawns a thread for watching a directory for new files. In this context, I have a method that runs in a ...
usr-local-ΕΨΗΕΛΩΝ's user avatar
1 vote
0 answers
462 views

TCP socket management using multiprocessing

I wrote a Python code for a device that generates an hotspot and communicates with an app using a TCP socket. The communication is managed by a process that opens a socket and uses two threads to send ...
firion's user avatar
  • 111
9 votes
2 answers
961 views

Multithreaded bogosort in Rust

For some quick context, I'm fairly new to Rust and decided to give myself a difficult-but-attainable task of implementing a sorting algorithm. I chose bogosort (or stupid-sort, shuffle-sort, whatever ...
LambBrainz's user avatar
0 votes
0 answers
43 views

Python scraper that gets product information from e-commerce website

I have built a scraper that scrapes data from e-commerce website and saves it to json using my own module. Although, I made the scraper multi-threaded, it starts slow, then speeds up and uses a lot of ...
dovexz12323's user avatar
2 votes
1 answer
3k views

tiny thread pool implementation

I wanted to write a minimal thread pool implementation. You can submit tasks and get a future. When the pool goes out of scope, all pending tasks will complete and join all workers. In an earlier ...
Raildex's user avatar
  • 133
1 vote
1 answer
326 views

Low-Latency Multithreaded Logger

My goal was to have a logger that does the blocking file I/O in a separate thread. A few notes: I made it a singleton rather than having a global "logger" variable, or a bunch of loggers ...
CaptainCodeman's user avatar
1 vote
1 answer
113 views

multiply matrices

I wrote a program that calculates the multiplication of two matrices (of compatible dimensions) where each element of the resulting matrix is ​​calculated by a separate thread. Each thread calculates ...
Mark's user avatar
  • 449
3 votes
2 answers
1k views

C++ thread pool and thread safe queue

This is my first time writing a custom thread pool in C++. I would love some feedback on how my code looks and if I am missing best practices or have glaring/subtle issues. Thanks! ThreadPool.hpp: <...
user2793618's user avatar
1 vote
1 answer
71 views

Re-usable worker pool classes

I am trying to read multiple files in parallel in such a way so that each go routine that is reading a file write its data to that channel, then have a single go-routine that listens to that channel ...
AndyP's user avatar
  • 229
15 votes
2 answers
1k views

A multithreaded implementation of the 'which' command

Here is an implementation of the 'which' command which can tell where programs are located. ...
JohnScott's user avatar
  • 171
1 vote
1 answer
2k views

Collect and combine results of async calls returning completable futures in Java in a cleaner way?

I need an abstract way to implement this below functionality because in my code I have to use it in multiple places with different REST endpoints. If I ignore it will cause code duplication. Please ...
tomsheldon's user avatar
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 ...
ROMSCore's user avatar
5 votes
2 answers
1k views

C++20 Single Queue Thread Pool

This is a follow up to my previous post. I've made a number of improvements to the thread pool and corrected some bugs as well. The most up to date version of the code is available on my Github. I ...
Developer Paul's user avatar
4 votes
1 answer
948 views

Simple parallel compression using Run-length Encoding in C

I encountered the concurrency-zip project in OSTEP By Remzi Arpaci-Dusseau. So basically, I've built a simple compression program that uses Run-length Encoding, and multi-threading in C. But I couldn'...
Richard H. Nguyen's user avatar
2 votes
0 answers
113 views

C++ logger for Windows

I have written a simple logger in C++ on Windows that I want to use to log info and errors from multiple threads to DbgView: ...
Andy's user avatar
  • 255
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,...
user1429322's user avatar
6 votes
2 answers
3k views

C++ Thread safe priority queue implementation

My first attempt at writing a thread safe priority_queue. It is not the most efficient because the locks can be even more fine grained if I add implementation of heap instead of using priority_queue ...
user1429322's user avatar
1 vote
1 answer
177 views

Bank account concurrency problem Swift

I tried to implement a simple BankAccount class to practice providing a solution to the common Bank Account transaction data race problem. Reference to a description of such a problem can be found ...
emrepun's user avatar
  • 165
2 votes
1 answer
2k views

C++14 Lock-free Multi-producer, Multi-Consumer Queue

Introduction This is a follow-up to a previous question of mine, where I presented another queue of the same type to get some feedback on it. Some people pointed out some fundamental errors I had ...
Primrose's user avatar
4 votes
1 answer
206 views

Task manager object for lazy initialization

The Problem I am developing a Visual Studio extension for importing code from a server. Because of the way Visual Studio works, multiple threads could try to perform the same operation at the same ...
trinalbadger587's user avatar

1
2
3 4 5
32