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
5
votes
1answer
119 views

Getting a transpose of a matrix of size of n*n where n=2^m using multithreading

The following is a c++ source code to get a matrix (std::vector<std::vector<T>>) transpose in parallel. The span is \$\Theta(\lg^2(n))\$ while the work ...
4
votes
1answer
48 views

Data segmentation and optimization for Multi-threaded/Multi-core use (In Python)

I have written a very basic algorithm, that counts the amount of times sub-string appears in a string. The algorithm is given: seq - a string sequence k - length of a sub-string L - a window of a ...
2
votes
1answer
45 views

Parallel SQL queries using completable future

My problem is I'm having a table and 7 child table. I'm fetching details using querying the main table first then querying the child tables one by one sequentially. To improve performance I decided to ...
2
votes
1answer
84 views

Cross-thread label countdown

Short and sweet... I wrote a cross-thread method that displays the countdown [in seconds] of a delay on a label. I'm fairly confident it's far from optimal, so I'm in need of that glorious ...
5
votes
3answers
100 views

Compute the value of a hand at contract bridge for every possible hand

Background At contract bridge, each player gets a hand of 13 cards from a deck of 52 cards. To evaluate the potential of a hand, we need to calculate what we called the High Card Points (HCP) of it. ...
1
vote
1answer
58 views

Banking application - Optimizing java multi-threading code

I created a simple Bank application to make multiple transactions between multiple accounts. It is working as expected. But I want to know can I make the code more optimized. ...
4
votes
1answer
49 views

One consumer and two producers using threads

I have based this code on Producer-Consumer Threading on Real Python. The idea is that I have 2 producers: One producer will give result every 0.4 to 0.7 seconds, depending on REST call. The second ...
4
votes
1answer
88 views

Multithreaded Message Game

Use cases Messaging app between two users. GameMain is for multithreading application refers to SendMessageWrokers.java Only 2 user need to be defined and message app needs to finalize after a ...
8
votes
2answers
681 views

A simple thread-safe Deque in C++

I am trying to implement a thread-safe deque in C++. ThreadSafeDeque will be used by a FileLogger class. When threads call the <...
4
votes
3answers
608 views

A simple multithreaded FileLogger in C++

In order to learn about multithreading programming in C++, I am implementing a basic multithreaded logger. I use a std::deque to store messages inside a ...
4
votes
2answers
67 views

Atomic fixed-size parallel std::vector wrapper

I'm in need of a simple wrapper for a fixed-size std::vector that can ensure atomic insertion. Since my only real problem is with atomic insertion and I know ...
4
votes
3answers
100 views

C++ Merge Sort Algorithm

I have created this first-timer implementation of Merge Sort and I got confused by the C++ syntax once or twice. So I have some questions about this code: ...
2
votes
1answer
62 views

Parallel MergeSort in C++

I've tried to implement parallel MergeSort in C++, that also tracks how many comparisons it's made and how many threads it uses: ...
5
votes
1answer
65 views

Decorator to instantiate class on another process

Motivation I want to run some compute heavy tasks on a separate process, so that they don't hog the GIL and I can make effective use of a multi-core machine. Where those tasks are pure functions, I'...
1
vote
1answer
70 views

Scoped thread using modern C++

I wrote this simple scoped thread to use it as a class member to ensure the the thread running on a class method doesn't continue running after the class has been destructed. Also to spawn threads ...
-1
votes
1answer
113 views

Instagram Scraper running to slow

Can someone help me how to speed up this scraping process getting all the usernames from the # 'cats' on instagram. My goal is to make this as fast as possible because currently the process is kinda ...
2
votes
0answers
66 views

Multi-threaded image convolution/pooling-python

This multi-threaded code takes an array of 3d images and applies the convolution function with padding, stride, pad values .. as parameters and same applies for creating pooling layers. I need ...
0
votes
2answers
97 views

Comparing performance between thread, task, parallel

I wrote some function to compare the duration taken for 1000 loops. Just wondering if the comparison is right? For the thread, I want to set to maximum 3 thread. Thread is ...
2
votes
1answer
54 views

C++ Fixed-size general-purpose thread pool

I've been reading about thread pools in C++ for a few days now and decided to roll out my own. I mainly intend to use it to learn how to implement parallel algorithms at some point in the future but ...
1
vote
0answers
99 views

ConcurrentDictionary performance

i need to improve the performance of ConcurrentDictionary. for that i created 2 classes for check if the more efficiencies than the original. ...
2
votes
1answer
89 views

Write strings to a file while downloading new one simultaneous

I created this console app that gets some JSON strings from a web request using a Parallel.For loop, ...
2
votes
0answers
79 views

Multi-threaded HD Image classifier using a neural network

This is a follow up to the code found here: Multithreaded HD Image Processing + Logistic reg. Classifier + Visualization Description: This code takes a label and a folder path of subfolders as ...
2
votes
0answers
34 views

Tkinter setup wizard-like application with threading

This is a big script with a GUI basically. I have 4 page classes, that are children of the main Wizard class. I do most of the threading in Step3 and the scripts ...
1
vote
1answer
84 views

A multi-thread Producer Consumer, where a Consumer has multiple Producers (C++17) - Part 2

This post is based on A multi-thread Producer Consumer, where a Consumer has multiple Producers (C++17). I am trying to build a Consumer that consumes data from ...
4
votes
1answer
49 views

Multi-threading with TPL - Access Internal Class Properties

I am using the TPL library to parallelize a 2D grid operation. I have extracted a simple example from my actual code to illustrate what I am doing. I am getting the desired results I want and my ...
5
votes
3answers
901 views

A multi-thread Producer Consumer, where a Consumer has multiple Producers (C++17)

EDID: Thank you very much for your feedback. I updated the code and opened a new post for the updated version. See here. This post is loosely based on A multi-threaded Producer Consumer with C++11. ...
4
votes
0answers
100 views

Is this Java small pubsub memory implementation correct and effective?

We want to provide a simple Redis pub/sub alternative in memory for our software. So we implemented this : ...
2
votes
3answers
76 views

Java file analyzer byte-by-byte

This is part of this topic. Problem: I need to read a file with BigIntegers and make some analysis "on-the-fly" with each read number (get prime numbers count, get armstrong numbers count). Right now ...
6
votes
3answers
232 views

Data analysis program for job interview

Before the interview for the Junior (i hope:)) position of Java developer, I was asked to do a test task. Kindly ask you to review my code. Riht now program arguments are hardcoded and not from args[],...
1
vote
1answer
40 views

Java implementing task on another thread with javascript-like promise resolve-reject

Background: I have a TCP online multiplayer game server, which the player requests to log-in. However, the game server does not handle the authentication part of the login process, instead, it uses ...
1
vote
1answer
52 views

Starting an activity after 1000ms from a splash screen with Runnable and Handler().postDelayed

I have implemented a splash screen which is the main activity of my Android app. This splash screen shows an image, and after 1000ms there is an animation to show another activity's layout. The code ...
2
votes
2answers
120 views

ICMP ping all hosts in a range

I'm creating my own little toolbox for pinging IP interfaces (for the test, only in localhost). In the future I'm thinking of piping the output to a text file. But I'd like to focus on improving the ...
4
votes
1answer
128 views

It's Teetime; adding tee like functionality to Popen

I recently needed to run some command line applications from Python. Whilst this is fairly simple with subprocess.Popen. I wanted to be able to properly pipe the ...
2
votes
1answer
53 views

Processing all files in directory

DO NOT RUN THIS EXAMPLE BLINDLY, IT REMOVES ALL FILES UNDER argv[1] Hello, This little programm should read all files from a given directory and do some work with them. New files are constantly ...
2
votes
1answer
81 views

Thread Pool in C for web server

Please review the following code for thread pool in C (I wrote it to implement a threaded web server for my personal project). I have been programming in C++ and Java but never did any serious ...
2
votes
1answer
73 views

Python multi-threaded kubernetes watcher

My program (which eventually will be containerised) should be able to do the following: continuously listening for deployment and daemonsets in kubernetes (2 threads) collect info needed (like ...
2
votes
0answers
38 views

Log tailing socket server

Each client application would send a filepath and search term to the server. The server then takes that file path reads the file and returns any lines that contain the search term, the server then ...
-1
votes
1answer
81 views

Calculating the value of Pi with Monte Carlo

I made this code to calculate pi using MonteCarlo method. I'm also learning how do Java threadpools and multithreading work. Can you tell me if this method is thread-safe and how can I improve it if ...
5
votes
0answers
113 views

Liveness monitor : python and RabbitMQ together through Pika

I'm a beginner using Python, and I'm trying to implement a functionality of a monitor program already developed by an other programmer. This program is working on a Windows machine (made by Inno ...
2
votes
1answer
165 views

Multi-threaded LinkedList Implementation

I am learning to write a multi-threaded linked list class implementation with basic functionality such as push to front or back, ...
3
votes
1answer
80 views

Code to print even and Odd number using two threads

Below I am giving you my code which I wrote to print even number using even thread and odd number using odd thread sequentially. Could anyone please validate my code whether it is correct way of ...
7
votes
1answer
564 views

Simulate a pool using multithreading in Python

I was tasked with solving this particular problem: A water pool which can hold a total of 800 liters of water has 3 pipes. 2 of them pour water in, the third one pours water out. 1st pipe pours ...
3
votes
4answers
178 views

Multi-threading slower than expected from single-thread loop [closed]

The following code is an experiment that I ran to play with the advantages of multi-threading in C++. Given a number 10000000000 it calculates how many numbers are ...
2
votes
1answer
292 views

Simple Producer-consumer implementation in Python

I implemented a simple solution to the Producer–consumer problem that I'd love for you to take a look at. The producer simply adds random numbers to a queue and the consumer (from a separate thread) ...
5
votes
1answer
231 views

Ultra fast Amazon scraper multi-threaded

This is a follow up to the code here: Web scraper that extracts urls from Amazon and eBay A multi-threaded modification to the previous version that is Amazon focused and most of the necessary ...
3
votes
1answer
41 views

Finding similar items in two arrays with multithreading in C++

I'm exploring multithreading for some code that I want to speed up in C++. I wrote a simple program to facilitate my understanding. The program takes in two arrays of equal length, the value of the ...
1
vote
0answers
34 views

Find parallel-base left-truncatable primes

Factorial base - representation of numbers not as sums of base_number^digit_number, but as sums of digit_number! (factorial). So 7 (decimal) is represented as 101_! in factorial base, because 7 = 6+1 =...
1
vote
0answers
40 views

Thread await and execute different methods based on some event or value

Use case: I am writing a proactive session updater; The use case is for parallel API calls or sequential API calls intercept the API call and check whether token is valid. If token is valid ...
11
votes
2answers
328 views

Self-inflicted killing utility

If you need to kill the same process that you're in (for testing purposes or whatever) this code will do it. A definitive, quick, unmerciful dead of the current Java program/app. Not a System.exit(0) ...
1
vote
1answer
236 views

Unisex Bathroom problem with semaphore

An office has a bathroom that can be used by both men and women, but not both at the same time. If a man is in the bathroom, other men may enter, but any women wishing to use the bathroom should wait ...

1
2 3 4 5
28