Questions tagged [multithreading]

Multi-threading is how work performed by a computer can be divided into multiple concurrent streams of execution (generally referred to as threads).

Filter by
Sorted by
Tagged with
1
vote
1answer
38 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 ...
11
votes
2answers
1k 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. ...
2
votes
2answers
150 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. ...
5
votes
2answers
389 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 ...
1
vote
0answers
66 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 ...
3
votes
1answer
57 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. ...
3
votes
2answers
96 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 ...
3
votes
2answers
78 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 ...
1
vote
1answer
55 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 ...
1
vote
1answer
73 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 ...
0
votes
1answer
55 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 ...
4
votes
2answers
93 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 ...
1
vote
1answer
28 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 ...
1
vote
1answer
56 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 ...
1
vote
1answer
71 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: ...
4
votes
3answers
62 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, ...
-1
votes
2answers
152 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 ...
2
votes
2answers
44 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 ...
2
votes
1answer
62 views

Multithread or multiprocess [closed]

This is my code: ...
1
vote
1answer
58 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 ...
4
votes
1answer
102 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, ...
4
votes
2answers
97 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 ...
-2
votes
1answer
83 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. ...
1
vote
0answers
35 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: ...
1
vote
1answer
40 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. ...
6
votes
1answer
109 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 ...
2
votes
0answers
32 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 ...
1
vote
2answers
219 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 ...
0
votes
1answer
110 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....
0
votes
1answer
105 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 ...
2
votes
0answers
33 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 ...
20
votes
3answers
2k 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, ...
1
vote
1answer
85 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 ...
3
votes
2answers
89 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 ...
2
votes
3answers
90 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 ...
3
votes
2answers
262 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 ...
-1
votes
2answers
198 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 ...
3
votes
1answer
54 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/...
1
vote
0answers
25 views

Building a generic WebSocket component in Python

I have the following working code for a generic WebSocket component: ...
5
votes
0answers
179 views

Multithreaded pathfinding in Unity C#

I've tried to implement multithreaded pathfinding in an attempt to increase performance, but if anything, performance seems to actually decrease when I enable multithreading. Is there anything I ...
3
votes
4answers
573 views

Multi-threaded merge sort

Below is the code for merge sort using multithreading. Will this code run for large number of inputs? Does any other part of the code need changing? ...
2
votes
1answer
105 views

Brute Force Password Program / Python 3.9

I've been making a brute force program for fun. This program tries to guess a password using brute force. I've tried many things to help increase the efficiency. Here it is: (Sorry for the lack of ...
4
votes
2answers
111 views

Spring Boot API - Avoiding Concurrency issues

I'm still in the process of learning Java / spring and I think I'm getting better. Now at this point I'm able to build a rest api BUT I'm at a lost at how to ensure I've no concurrency issues . I've ...
1
vote
1answer
93 views

What is wrong with this CancellationTokenSource example

Anybody mind providing an opinion on whether or not this is a good or bad example of Task Cancellation and why. I have my own opinion and I've been told that its baseless, just trying to find out who ...
1
vote
1answer
42 views

Android APP FTP host profile class implementation

This is a follow-up question for Android APP connect to FTP server in Java. I am attempting to create a tiny FTP host manager with FTPHostProfile class and ...
2
votes
1answer
256 views

Single Producer - Multiple Consumers in C++11 using Linux Threads

Hey everyone I was redirected here from Stack Overflow for this question. I am completely new to thread synchronization using condition variables and pthreads in Linux. Here is the code I wrote and I ...
2
votes
2answers
138 views

Write deduplicated 9-digit numbers from concurrent clients to a log

Problem Statement: Write a server (“Application”) in Java that opens a socket and restricts input to at most 5 concurrent clients. Clients will connect to the Application and write any number of 9 ...
3
votes
0answers
213 views

Android APP connect to FTP server in Java

I am attempting to build an Android APP with the ability to connect specified FTP server in Java. The connection operation has been performed in FTPconnection class ...
9
votes
3answers
2k views

Finding number of primes less than 10 million using a multithreaded program

I recently decided to learn how to multithread Java programs, so I made a small program to compare the performance of serial and multithreaded programs that perform the same task. I created a serial ...
2
votes
1answer
66 views

The multithreading model to clean ConcurrentQueue in C#

I have some code that populate EventfulConcurrentQueue which is ConcurrentQueue. So I need to save all data from ...

1
2 3 4 5
31