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
8
votes
2answers
671 views

C# threading and synchronizing methods

So I started this question, I believe i have synchronized the methods correctly, need some insight on whats wrong and what should be done. I have to modify ths class Purse so that the method AddCoin ...
3
votes
0answers
43 views

Running DNS lookup over million IP addresses

I need to run over all the IP addresses on the CIDR 10.96.0.0/12 network. There are 1,048,574 IP addresses. I created a multi ...
1
vote
0answers
41 views

Is it thread safe? [closed]

I'm working on a class that provides my application's start and stop method. Those methods can be called from different threads and I'm wondering if my solution is proper. Notes: ...
5
votes
1answer
39 views

Prototype of background save facility

I have developed NoSQL database. At the moment it has no threads (async). When the database needs to save data to disk, it blocks connections until it saves. This method works OK, because save is fast ...
3
votes
2answers
66 views

Implementing metropolis algorithm in C

This is my second C program (an improved version of the first one). I want to optimize this simulation. Algorithm The simulation algorithm is: The system can go from \$i\$ to \$i+1\$ with probability ...
1
vote
0answers
20 views

QT thread with timer

I have a qt code that opens some threads and waits for a response, all timed with a QTimer. For example (thread1 is declared in the header) ...
1
vote
1answer
65 views

Thread-safe event-queue code appears to work, any possible race conditions, deadlocks, or other design problems?

Cross-Posted from Stack Overflow I am new to using condition_variables and unique_locks in C++. I am working on creating an ...
1
vote
0answers
31 views

OpenCv webcam streaming class for WPF

My goal is to make a class that wraps the complexity of OpenCvSharp implementation to show a webcam streaming into a WPF Image. ...
4
votes
3answers
80 views

Ensuring threads running infinite loops are terminated before exiting the program

As a hobbyist programmer, I gain knowledge where I can find it from google searches. I tend to write code that utilizes threads that have infinite loops using while loops, where the while condition ...
5
votes
1answer
260 views

Server in Python

I'm looking for a code review and code improvement for my own small server. The server accepts the requests: User Join,User Leave,User Text Notify Group Join, Group Leave, Group Notify Request Time. ...
2
votes
0answers
71 views

C++ threaded task manager

I've been writing a little task manager in C++ in my spare time. It's also the first time I am posting here for a review, I hope someone can spot any mistakes. There's still a lot to implement and ...
4
votes
2answers
96 views

C++ multithreading logger class

I have designed a logger class to log messages to a file. It uses an independent thread to log the messages save to a queue previously using the main thread. I want to receive reviews about it. ...
0
votes
3answers
123 views

Fastest way to create random pixel image

I want to create a very big gigantic PNG image. The image pixel are generated randomly, being How can I improve the below code to create a fast random pixel image in java? ...
1
vote
0answers
48 views

Lock free ring buffer

I am hoping that someone can take a look at my implementation of a lock-free ring buffer and critique the implementation. I'm hoping that the focus can be of the correctness of the atomic operations ...
4
votes
1answer
81 views

Bank with factory method for accounts, multithreaded deposit and withdraw

I have a couple questions about this program Should I implement runnable instead of using thread class? I like the idea of the consumer and producer being thread objects, it seems simpler to me, but ...
7
votes
1answer
52 views

Design elevator to get user commands and execute request based on current elevator moving direction (UP/Down)

I have created an simple elevator design for 100 floors building with just one elevator. I have dependency between classes which I want to eliminate, any thoughts/suggestion to make it more better in-...
3
votes
1answer
69 views

Rust multi-cliented TCP Server library

I am new to Rust, so I created a mini library/wrapper for creating multi-cliented Tcp Servers. This is a starter project for me to learn Rust. How the module works is a user can pass in a function or ...
2
votes
1answer
91 views

C++20 sort of infinite “Consumer-Producer”

I think I can summarize the idea to the Producer-Consumer problem, with some modifications. And I think i misused the term "Producer" (it depends from which point of view :)) An infinite ...
5
votes
1answer
70 views

Count of request per second, minute in java

I want to count number of requests per second, minute. I want do it fast and thread-safe. I have 2 variables to count: ...
0
votes
0answers
18 views

Use cURL and threads to make API calls

Requirement We use a tool where we have Jython as one of the scripting languages available for making custom scripts. The requirement is that we need to make multiple API calls (in parallel) and ...
5
votes
1answer
65 views

Multithreaded console-based monster battle with earliest-deadline-first scheduler

In working on this answer it occurred to me that it might be interesting to further expand the idea. The game This is an extremely simple (and boring!) text-based game that creates a few monsters ...
4
votes
1answer
634 views

Barrier implementation in C++

I've implemented a barreir in C++ close to one showed here. In the project code it's used only with two threads and seems to work. A synthetic test didn't expose any flaws too. But I suspect that on ...
9
votes
2answers
144 views

N-Body Optimization

I've created a serial C++ code for gravitational N-Body calculation. Because I expect to have upwards of 8-71 sparse bodies (ie, where Barnes-Hut is not necessarily practical) and running for long ...
1
vote
0answers
59 views

Is it good idea to use expensive LINQ calls under heavy load?

I am working with cassandra using datastax c# driver. I need to pull data out from three different tables. Below is my code which does the job. ...
4
votes
1answer
56 views

Job_Queue (Thread_Pool) Program

I'm new to std::atomic, std::mutex, std::unique_lock, ...
3
votes
1answer
60 views

Rate limit a method by generating particular load on demand in C#

I am working on a project where I want to generate random throughput on a particular method so that I can do some performance testing on it. This way I can test my method by generating random ...
2
votes
1answer
47 views

Java multithreaded withdrawal and deposit banking

i'm exercising Java multithreading on an example of simple banking funcions. The programm is able to perform multiple transactions at once on different threads.All accounts transfer money to the ...
2
votes
3answers
117 views

Logger which writes asynchronously to file from multiple threads

I have written a simple logger, AsyncFile, which asynchronously writes data to a file. Since data is going to be written very often (E.g. 10 writes per 30 milliseconds from different threads, my ...
2
votes
0answers
482 views

My Java matrix multiply code single thread faster than multithreading, any mistakes?

I'm implementing the matrix multiply function using Java's multithreading. Below is my code: So I first tried the normal single threaded approach, then tried the ExecutorService approach, I don't know ...
2
votes
1answer
37 views

Example using Object lock synchronized blocks

Here's my attempt at trying to understand synchronized() blocks using an Object lock, using wait() and ...
3
votes
1answer
63 views

Timeout thrower using multithreading

I designed a simple timeout thrower for a bluetooth protocol I am writing. If the packet is not received in a certain amount of time, then timeout is thrown. I made it to be as plug and play as ...
0
votes
1answer
46 views

A collection of tasks and their CancellationTokens

I have a task wrapper which stores tasks, their CancellationTokens and of course their names (botName). ...
1
vote
0answers
21 views

Simple header-only thread and mutex for both windows and linux in C

I wanted to get some thread support on windows with very simple headers for a library that I'm working on but it had to work on both Windows and Linux. Since C11 threads are not widely supported, this ...
1
vote
1answer
41 views

Concurrent Queue with enqueue and dequeue using Stack as underlying data structure

This is a mix of data structure and multi threading concept based question. (This is only for understanding and learning purpose) The language for the solution : Java A Queue with FIFO behavior needs ...
3
votes
1answer
38 views

C code using process synchronization and multi-threading

This is a matrix-vector multiplication program using multi-threading. It takes matrixfile.txt and vectorfile.txt names, buffer size, and number of splits as input and splits the matrixfile into ...
3
votes
2answers
67 views

Multithreaded for-each for index based bata structures

As part of an utilities "library" I'm putting together I've worked to make a multi-threaded for-each that splits a job of applying a function to each element of an index-accessible container in ...
1
vote
1answer
58 views

SQLite and Python: commit once every 10 seconds maximum, and not after every client request

In a Python Bottle server using SQLite, I noticed that doing a DB commit after each INSERT is not efficient: it can use 100ms after each client request. Thus I wanted to improve this in How to commit ...
8
votes
3answers
117 views

Command line based game with players and monsters

I am coding a command line based game with 1 player and 2 monsters. Monster attacks player at specified intervals and player takes input from standard input to attack specific monster. I would like ...
2
votes
1answer
62 views

A new CHAMPion - Compressed Hash-Array Mapped Prefix-tree in C

I implemented an immutable hash map in C, as described in this paper. First, my design goals: plug-and-playable: compile with gcc -O3 -std=c11 champ.c, ...
3
votes
2answers
90 views

Easy to use Thread Pool Implementation

awhile ago I asked about a thread pool implementation I had made. I took the advice down and modified it a lot over time to fit my needs. It has been serving me extremely well in all of my projects ...
1
vote
1answer
48 views

Goroutine wait select operation on multiple channels

I'm trying to understand an SO answer for this question Golang select statement with channels and waitgroup. The author of the now accepted answer goes on to say that OP's code is almost similar to ...
2
votes
0answers
37 views

Utilising pymongo to scrape over 4 million urls using multiprocessing to examine the impact of coronavirus

So I want to do some research on the impact covid 19 is having on businesses. I've managed to generate a database with the company name and the website urls associated with it. Now I want to scrape ...
3
votes
1answer
65 views

Thread safe reader-writer queue with C++11

Below is my honest attempt to write thread safe queue using C++11 features. Please review it and provide your comments. ...
1
vote
0answers
81 views

Recursion - Max of integers in slice

Logical processors available on my machine: CPU(s): 4 Thread(s) per core: 2 So, 2x4 = 8 logical processors. But am currently using only 4 go-...
5
votes
1answer
134 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
59 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
58 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
89 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 ...
6
votes
3answers
105 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
69 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. ...

1
2 3 4 5
28