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
0answers
19 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 ...
3
votes
1answer
36 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
651 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
83 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
64 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
210 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
37 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
42 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
110 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
76 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
51 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
55 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
48 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
36 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
69 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 ...
4
votes
0answers
90 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
112 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
79 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 ...
1
vote
0answers
94 views

Animal class with Threads and factory

it's my first time working with threads and I had this Homework to solve: Homework Text: Program a class called Animal. Animals have a spatial position that represented by an x ​​and a y coordinate (...
7
votes
1answer
552 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
135 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
72 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
200 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
39 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
39 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
326 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) ...
0
votes
0answers
109 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 ...
4
votes
2answers
147 views

Swift main thread style

I run into issues where I forget to run UI changes on the main thread. I've just fixed an issue for loading and unloading an activity indicator and fixed it with the following code: ...
10
votes
1answer
472 views

C++ Standard-Thread Threadpool

I have written a small and simple ThreadPool class for rather simple multithreading applications. The Threadpool class manages ...
12
votes
2answers
1k views

Implementation of a Thread Pool in C++

I wanted to implement a thread pool to test my knowledge of various modern C++ features. The end result could be better, but I need a review as I'm not sure about delicate things especially regarding ...
0
votes
0answers
46 views

Setting Timeout For Scheduled Task In Java

I am trying to set timeout for tasks which executed by scheduler in Java. I managed to write necessary codes, they are working well but I guess something is not right. I have scheduler's thread pool ...
4
votes
1answer
57 views

A thread that can be interrupted before starting

As per the Java documentation: Interrupting a thread that is not alive need not have any effect. Particularly, interrupting a thread between the call to start() and the invocation of run() has no ...
5
votes
3answers
131 views

Effective fetching data algorithm

I'm fetching some data by using bs4, and want to know why access speed gets slower as my program progresses. I'm using thread, and I know threading isn't so fast because of GIL. My problem is that ...
2
votes
1answer
138 views

Modelling a Call Center in Java (multithreading approach)

I wanted to give a shot to Modelling a Call Center from Cracking the Coding Interview. The problem statement is as follows: You have a call center with three levels of employees: Respondent, ...
3
votes
1answer
63 views

Using a thread to update a table automatically in Django

For my portfolio app using Django I made a thread that pulls out the usd exchange rates for various currencies every 6 hours and updates the database. The program kicks in as soon as the module ...
4
votes
3answers
362 views

Process queued data in the background

Currently I'm writing something like a messaging or logging framework (I'm not really sure how you name something like that). There are different servers which have to be notified if something happens....
6
votes
2answers
253 views

Action queue manager to perform action in a FIFO fashion

Recently, I needed a class that could execute code in a FIFO fashion in order to update parts of a WinForms or WPF UI which did not block the UI Thread and left the UI responsive to any interaction ...
7
votes
2answers
65 views

TaskScheduler in python

I have found the need to schedule a few simple functions in a first-come-first-served way so I developed a small task scheduler based on multiprocessing and I thought it would be a good candidate for ...
1
vote
0answers
62 views

Fast text search in Rust

I have a large file that I want to search for text as fast as possible. There is not a memory contraint, so I am loading the entire file into memory so that I can use the rayon parallelism crate in ...
5
votes
2answers
180 views

Process multiple request from different threads in batches on one processing thread

So I have a system that uses multiple threads to process data. These data could be processed individually but it would be better to process them in batches. Lets assume we have a class ...
2
votes
1answer
75 views

Multithreading to process requests and save results in python

I was presented with a task to come up with a script that generates a CSV with POSTAL codes via bruteforce (I'm in Brazil, so that means CEP to us). Points to note: I'm using an external library, ...
2
votes
0answers
49 views

Motor control PLC in Python

Project description We have different types of devices like sov, motor, analog, digital, control valves etc. Each type of device has 100 items. Now our software continuously monitors with the PLC to ...
7
votes
2answers
152 views

Python-style Generator in Java

I have implemented Python-style generators within Java. I might be reinventing the wheel here, but I feel that the ability to define a Generator with an anonymous class is the most flexible approach. ...
5
votes
4answers
496 views

Thread-safe, Convenient and Performant Random Number Generator

I need to generate a lot of pseudo-random numbers in my software. I'm trying to create a elegant (syntax-wise) and performant class that would allow me to generate such numbers and perform other ...
12
votes
5answers
742 views

Reducing contention in thread-safe LruCache

I was looking for a in-memory cache class, but couldn't find any in the .Net Core framework; luckily I found one already implemented here. I made some minor modifications to it and tried to make it ...
2
votes
2answers
167 views

Server and Client programs for guessing game

I recently had to complete this for a school assignment and I really enjoyed it, but was hoping someone with experience in OO design or maybe just Java in general could have a look and point out ...
2
votes
0answers
40 views

Execute a command repeatedly until a stop message is received

I'm trying to create a script that receive command from other script, and based on the command received it will execute a method with a while loop or stop it. I manage to make it works with the code ...
6
votes
2answers
81 views

Would log4j be more efficient to utilize than the logger I implemented (Code Below)?

I recently made a logger program implementation in my game engine. Which logs any thing that I send it in either a file or the System.out printstream. I use it like this: ...
1
vote
0answers
37 views

Invoking parallel threads of a nslookup command in python

I've written below python script just to invoke parallel threads of a command nslookup linux-host01 dns-server, i'm Just trying to flood the DNS Server ...