Questions tagged [multithreading]

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

Filter by
Sorted by
Tagged with
15 votes
2 answers
2k views

Block-free priority lock

Background I wanted to write an event loop that supports scheduling, but found that no implementation of priority queue that I know of supports waiting on a condition variable (the idea is that the ...
Incomputable's user avatar
  • 9,374
3 votes
1 answer
395 views

Leaky Bucket algorithm with concurrency

Trying to mimic a scenario where multiple threads are creating the traffic to fill the buckets & a thread which leaks the bucket at a specified rate. Could you review this code? ...
user8707488's user avatar
0 votes
1 answer
96 views

Implementing Database Connection Pooling

I am re-implementing a web-application, partially as a learning exercise to learn nim as well as multi-threaded programming. As part of that learning exercise, I want to implement connection pooling ...
Philipp Doerner's user avatar
1 vote
1 answer
65 views

c++ multithreaded message broadcaster with link lifetime management v2

note: This is v2 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?). Code is ...
Diederick C. Niehorster's user avatar
1 vote
1 answer
59 views

c++ multithreaded message broadcaster with link lifetime management

note: A version of this code without link lifetime management was previously reviewed. Adding lifetime management actually made the code simpler, and the class simpler to use. I have written a class ...
Diederick C. Niehorster's user avatar
1 vote
1 answer
58 views

Dividing shared resources for homogeneous multithread processing

I'm trying to implement a homogeneous multithreading example that multiple threads process portion of a huge task. In order to achieve this, I thought of clustering data/resource and multiple threads ...
YoonSeok OH's user avatar
4 votes
1 answer
135 views

Binary Thread Scheduler

The term, I used, binary thread scheduler means a scheduler that orders the execution of two threads for two tasks that has a specific dependency. Rather than using some mathematical expressions to ...
xiver77's user avatar
  • 421
1 vote
2 answers
943 views

sum of array using multithreading

I implement sum element of array using multi threading but my question is when my program work with one thread the time is better than using 6 thread . I am using a CPU with 8 threads.What am I wrong <...
Filip Resceanu's user avatar
0 votes
1 answer
53 views

Type-agnostic abortion condition in Producer-Consumer model queue

This is a follow-up post to the topic discussed here. Description I am trying to implement a robust, multi-threaded producer-consumer model with a single producer in the main thread and several ...
DocDriven's user avatar
  • 161
5 votes
1 answer
977 views

Multithreaded Producer-Consumer model implementation

Description I am trying to implement a robust, multi-threaded producer-consumer model with a single producer in the main thread and several consumers in other threads. The generator thread loops over ...
DocDriven's user avatar
  • 161
1 vote
2 answers
415 views

Replacement for starting threads from a for loop

I have the following code: ...
eaRobust's user avatar
2 votes
0 answers
552 views

Parallel Breadth First Traversal in Rust

Overview I have been writing my own graph API for Rust and one thorny problem I wished to tackle was a parallel breadth first traversal of the graph. The API itself will have different graph flavours, ...
Julius's user avatar
  • 171
2 votes
1 answer
240 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 ...
ng.newbie's user avatar
  • 171
11 votes
3 answers
2k views

Multi-threaded web server serving HTML, images, etc

I have a web server that can send websites, images, mp3 and other things and I was wondering how I could improve the code and make the server more efficient. ...
logsInMyEyes69's user avatar
2 votes
2 answers
1k views

Sum of 2 arrays using multi threading

I'm trying to implement sum of 2 array using multi threading. I expected that when I use more threads it will be faster than when I use one thread, but that isn't the case. ...
Filip Resceanu's user avatar
5 votes
2 answers
3k views

C++20 Thread Pool

I've implemented a thread pool using C++20. I'm fairly new to concurrently/multi-threaded programming and wanted to work on a project that I could learn from while also getting to know some of the new ...
Developer Paul's user avatar
2 votes
0 answers
694 views

Multi-producer/single-consumer queue in Python

I am currently working on a problem that involves multiple producers and a single consumer through a queue object. The following list is about a few things that's special about this problem: One ...
dhu's user avatar
  • 327
3 votes
1 answer
725 views

Real time histogram using multithreading (Qt + Qwt)

I'm writing a GUI for different VME modules (electronics). There are several of them which are used for the data acquisition. For example, an ADC produces the digitized maximum voltage on its input. ...
LRDPRDX's user avatar
  • 781
3 votes
2 answers
197 views

C++11(14/17/20) Thread Management

I'm implementing something of a thread janitor in modern C++. What I've got works, and while it's not organized in the way I'd like yet, I'd like some feedback on the fundamentals. Thank you in ...
pdm's user avatar
  • 307
3 votes
2 answers
387 views

C++11 revised `std::latch` implementation

This question follows up on this question. After turning the while-loop into a conditional wait using std::condition_variable, I ...
noes's user avatar
  • 43
1 vote
1 answer
288 views

Implementation of a latch

As an exercise to learn more about multi-threading and atomic operations work in C++, I decided to implement a latch class in C++11 loosely based off of std::latch ...
noes's user avatar
  • 43
1 vote
1 answer
727 views

Printing odd and even numbers in separate threads C++

I recently saw a youtube video on printing even and odd numbers from 0 to 100 in Java. https://www.youtube.com/watch?v=eRNTx8k5cmA Thread 1 prints even numbers and thread 2 prints odd numbers. Both ...
elMuon's user avatar
  • 11
0 votes
1 answer
65 views

Showcase difference multiprocessing and threading in Python

This week I dived into the issue of speeding up my program by either threading or multiprocessing. I did not understand well the difference between the two, but that became quite clear when I got the ...
Bruno Vermeulen's user avatar
4 votes
2 answers
803 views

2 Threads taking turns printing the alphabet

I am supposed to write code for an assignment. The goal is to make 2 threads (which are objects of a class that implements runnable) take turns printing the alphabet. One of them prints upper case ...
TheWerefox's user avatar
1 vote
1 answer
50 views

Mean and variance of element-wise distances in a set of multi-dimensional arrays in Matlab

This is a follow-up question for Calculate distances between two multi-dimensional arrays in Matlab. Given a set SX $$ S_{X} = \{ { X_{1}, X_{2}, X_{3}, \dots, X_{n} } \} $$ where n is the count of ...
JimmyHu's user avatar
  • 3,984
2 votes
1 answer
862 views

Hashing with python optimization, hashlib and multiprocessing

I am looking to get any type of improvement, I want to be able to hash a list of 'blocks' aka strings and check if hashes match per block, if you can help me with that, currently reading and writing ...
R0Best's user avatar
  • 75
1 vote
1 answer
141 views

pointer jumping on a GPU using Aparapi

Classic pointer jumping algorithm summarizing values from an array adapted to run on a GPU instead of a PRAM. Read about openCL and Aparapi yesterday for the first time, so this is my first trial: ...
morgwai's user avatar
  • 151
5 votes
3 answers
186 views

Python 3 Multi-connection downloader

I have written a fully functional simple command line multi-connection downloader, written in Python 3, using just threading, ...
Ξένη Γήινος's user avatar
-1 votes
2 answers
181 views

A simple java game engine [closed]

I'm starting an object orientated game engine in Java. My plans for the engine is to be able to split things easily into multi-core loads. My idea is that a Unique (interface with a ...
tuskiomi's user avatar
  • 185
2 votes
2 answers
327 views

Avoid global variable due to executor.map()

I'm pretty new to python but after watching Mr Robot I felt inspired to make a CLI portscanner. With all the fancy console outputs you see in movies like a progress bar. It's finished and works nicely ...
George R's user avatar
  • 221
2 votes
1 answer
123 views

Multithread or multiprocess [closed]

This is my code: ...
teneji's user avatar
  • 21
1 vote
1 answer
268 views

Validate Empty Sudoku: Multi-Threaded Solution

The problem is that we have an unsolved sudoku board, and we want to validate it, we need to check each column, row and sub-square. Here we represent a empty cell with -1. My idea was to create a ...
AKRA's user avatar
  • 155
4 votes
1 answer
527 views

Python multi-connection downloader

This is a simple Python multi-connection downloader primarily using requests, mmap and threads, it downloads a single file using 32 concurrent connections, slices the download using range parameter, ...
Ξένη Γήινος's user avatar
4 votes
2 answers
161 views

Longest Palindromic Subsequence Multithread in C

I'm trying to learn how to multithread with c, and thought that the longest palindromic subsequence problem would be a good place to start. The idea is that we run two threads and compare their ...
AKRA's user avatar
  • 155
-2 votes
1 answer
96 views

Thread-safe collection to store Member objects [closed]

This is poorly written Java code, intended to implement a thread-safe collection to store Member objects and failing at doing so. ...
Barcelona's user avatar
  • 105
1 vote
0 answers
48 views

Thread-safe running mean and variance

In one of my personal python libraries I have a custom class used for computing the running average and variance of a stream of numbers: ...
Mate de Vita's user avatar
1 vote
1 answer
94 views

Daily coding problem: Job scheduler invoking a function after specific time

This is a problem from Daily Coding Problem. I have implemented it in Java. For a function f I have used Runnable interface. ...
Michał Dobi Dobrzański's user avatar
6 votes
1 answer
551 views

C++ producer-consumer using blocking buffer

I'm working on a programming exercise (university, nothing related to industry) which basically asks to implement a Buffer to be used by two threads (a producer and a consumer). The first one enqueues ...
Elle's user avatar
  • 163
2 votes
0 answers
39 views

How to check gcp pupsub empty/inactitve subscribtion

I have an application that subscribes to a topic in GCP and when there is some messages over there it downloads them and sends them to a queue on ActiveMQ. In order to make this process fast I am ...
elmodeer's user avatar
1 vote
2 answers
776 views

Using multithreading to send multiple emails

I'm trying to send any number of emails in the shortest amount of time using .NET 5.0? I've been playing with something like the following but I am not sure if it is optimal or even correct as there ...
Jonathan Wood's user avatar
0 votes
1 answer
672 views

An async time-based rate-limiting semaphore for C#

This is a class that allows only limited number of requests to proceed per period of time. This is designed for use with external APIs that require such rate limiting, e.g. 600 requests per 10 minutes....
Bob's user avatar
  • 459
0 votes
1 answer
330 views

Python best practices to impletent QThread, progressbar (pyqt5) and sniffer (scapy)

I'm new in python and I want to know the way to improve this code with best practices. I'm using PyQT5 to create new thread In that thread I'm using scapy to sniff traffic and filter ARP traffic to ...
user3819641's user avatar
2 votes
0 answers
49 views

Rust program to create mail.tm accounts

I have created a rust program to create https://mail.tm accounts, but I think there are things I could have done better. Are there things I can do to improve performance? Are there any unnecessary ...
cavalry1223's user avatar
22 votes
3 answers
6k views

C++ lock-free, MPMC Ring buffer in C++20

I have some performance critical inter-thread messaging code in C++. Multiple producers, one or more consumers. Profiling dozens of iterations of this messaging code over several years of development, ...
Ash's user avatar
  • 364
1 vote
1 answer
108 views

C++ Improved ThreadGroup Implementation

After the amazing feedback from these questions; I have prepared a third version of the original posted code. The Idea is the same: An std::size_t variable ...
Dávid Tóth's user avatar
3 votes
2 answers
295 views

C++ ThreadGroup Implementation

Edit: An improved code based on feedback is available here. As a kind of sequel to the previous question, here is an improved version( with clarified naming ). The Idea is the same: An integer ...
Dávid Tóth's user avatar
2 votes
3 answers
494 views

A file system watcher class for on-fly file reloading when it has been modified

I wrote a file sytem watcher class that is used to monitor file modification and then execute user-defined handler. Other file system events like moving or deleting don't need to be monitored. The ...
eanmos's user avatar
  • 395
3 votes
2 answers
486 views

C++11 ThreadPool implementation

A new version of this code based on the provided advice can be found here. Latest improvement is found here. I made a simple ThreadPool implementation in C++ using ...
Dávid Tóth's user avatar
-1 votes
2 answers
1k views

Thread-safe LRU cache in Python

I've written a simple LRU cache class and I am trying to make it thread-safe. My thoughts are that I just need to wrap the code that updates the ordered dict in a lock so that if any thread is writing ...
sleepyowl's user avatar
3 votes
1 answer
174 views

Particle swarm algorithm with multiple threads

I wrote a simple multitthreading program which does particle swarm optimization. Optimization itself and some corresponding functions were taken from https://nathanrooy.github.io/posts/2016-08-17/...
Mark Lumar's user avatar

1 2
3
4 5
32