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
9
votes
5answers
296 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
66 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
15 views

Right way to handle parallel API calls in Java [closed]

I have a web application in Java where as part of client HTTP request handling, I need to make 2 API calls. The way I am planning to implement is to offload 1 API call to thread pool and do the other ...
2
votes
0answers
34 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
58 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
26 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 ...
5
votes
2answers
117 views

PLINQ code analysis in terms of efficiency of cryptographic hashes generation

I have the following code that I wrote in order to find the correct password by generating hashes out of all possible combinations and comparing each of them with the target. I'm trying to make ...
2
votes
1answer
60 views

Implementing a thread pool for task execution

I wanted to experiment with a reusable thread pool that allows to add tasks and execute them repetitively. After going through, https://github.com/progschj/ThreadPool and another Stack Overflow post ...
4
votes
4answers
1k views

Unix chat server making communication between terminals possible

This Server handles clients communicating with each other. Because I was not willing to actually give every client a name, they are named by their socket's file descriptor. This is my first ...
1
vote
1answer
62 views

A minimalistic kind of read-copy-update class

This is a very simple read-copy-update (RCU)-inspired synchronization class: ...
3
votes
1answer
82 views

Cancelable AsyncLazy that is thread-safe

I've been thinking about the AsyncLazy<T> class that Stephen Toub and Stephen Cleary present in various resources such as this. I am trying to find a way to ...
3
votes
1answer
125 views

Simple sharding of delimited files to more sophisticated

A while back I came across the issue of having a large delimited file where I wanted to simply parallelize my python code across each line of the file. However, doing so all at once either took up too ...
3
votes
3answers
104 views

Thread-safe “singleton” that destroys object when not used anymore

I'm working on some legacy code which uses the singleton pattern. The problem I have with the traditional singleton is that the instance lives until the program terminates. This is messing up the ...
2
votes
0answers
57 views

Lock-free pooled queue

I am attempting to create a lock free pool of resources and I need the ability to access any one that is not already accessed and then return it back when I do not need it. This will happen very very ...
3
votes
1answer
58 views

Asynchronous hardware communication - Library Design

I've got some equipment ("tool") that communicates over CANbus that I need to communicate with. I'm using a USB->CAN dongle that provides a basic .Net control library. I'm in the process of writing ...
4
votes
2answers
376 views

Unisex Bathroom problem without semaphore

Could I ask you to evaluate my solution to Unisex Bathroom Problem? Problem description 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 ...
4
votes
1answer
103 views

Factorial calculation UI freezes on loading many items in ListBox

I've been experiencing this performance issue for about 3 days and really need your help. I'm a novice at c# and cannot understand what I can do to optimize my application. The problem is that the UI ...
3
votes
1answer
103 views

Invoking thread for each item in list simultaneously and returning value in Java

I made a wrapper for an API that I am using, basically what I'm doing is sending in a list of Series objects and for each item in the list, a thread ("worker"?) ...
2
votes
0answers
46 views

Mutex lock benchmark

I'm trying to measure how many CPU cycles a mutex lock takes. Can you find any problems in my mutex lock benchmark? ...
5
votes
0answers
29 views

Lightweight lock using OMP atomic

I am working on a Monte Carlo simulation using OpenMP multithreading. To avoid race conditions when multiple threads work on the same resolution element, I have implemented the following ...
2
votes
0answers
57 views

Parallel Miller-Rabin Prime Test in Haskell

I implemented a prime number finder using the Miller-Rabin prime test in Haskell and it seems to be working. You enter a number and it finds the next prime following that number. I also tried to make ...
4
votes
1answer
57 views

Suspend and resume a thread using signals

The other day I ran into this question on stackoverflow. Just for curiosity I wanted to implement suspending and resuming the thread, so I used signals and used ...
2
votes
0answers
12 views

Thread safe Shareable and Splittable Buffer with Safe Memory (Project)

Backstory This is a buffer I wrote for use in multiple personal projects. It is designed to handle pretty much any data in pretty much any way. In particular I intend to use it in such instances as ...
4
votes
2answers
65 views

Thread-safe stack in Java with fixed capacity

Implement a multi-threaded stack, with freedom to use existing implementations of stack. On top of being thread-safe, it must block (not busy-wait) a pushing thread when stack is full and a ...
1
vote
1answer
27 views

Two-Part Hurdle Model Simulation with Bootstrapping

I am running a simulation study where I am using two-part hurdle modeling on different effect sizes. I tried to stream-line my code for the best optimization including foreach loops and ...
3
votes
1answer
118 views

Determine concurrent access to a function

Someone asked here how to determine a function is being called from multiple threads. My take on this is that they are asking about concurrent access not sequential access. The accepted answer ...
7
votes
1answer
72 views

C++ Windows Directory Watcher

This was a small project I did the other day because I wanted to explore a solution to hot-reload some files in another project. My requirements were: Act in it's own thread Be able to watch ...
1
vote
1answer
61 views
8
votes
2answers
362 views

C++17 thread pool

I've implemented a thread pool in C++17. This is not backwards compatible with C++14, due to the usage of std::invoke_result, which is new to C++17. The focus of ...
32
votes
8answers
5k views

Thread Pool C++ Implementation

I have been working on this thread pool for awhile to make it as simple to use as possible. I need some tips on improving performance, and some good ways to test its performance. I was wondering if ...
5
votes
0answers
98 views

Java multithreading many readers one writer implementations

I have a shared data object with writer threads and reader threads. Number of threads can read from the shared data at the same time (in the code getmethod), and ...
1
vote
0answers
23 views

Process 2 lists concurrently with the first list adding to the second [closed]

I'm new to multi-threading and concurrency. I've got 2 lists that I want to process concurrently. Processing both lists requires a lot of time.sleep() and waiting for other servers to finish, so I ...
2
votes
0answers
61 views

Game involving finding words containing letters from a memorized list

I wrote this Java game where the user memorizes a list, gets given letters and needs to find a word that contains those letters. The player has only a few seconds to enter the word. Example: Program ...
1
vote
2answers
182 views

Multi-Threaded Cellular Automata Lab

I am trying to improve the performance of my cellular automata lab. I have two arrays of Doubles representing the current values and the next values. If I run the ...
1
vote
0answers
56 views

First readers-writers problem using a single condition

For the first readers-writers problem, in which readers can access a given resource simultaneously, is the following Python3 solution correct? Problem parameters: One set of data is shared among a ...
8
votes
0answers
46 views

Parallel merge sort with thread- and bufferpooling

I did wrote this parallel merge sort with no external dependencies. I tried to make use of modern C++ as much as possible. Can you please tell me how it is? ...
1
vote
0answers
20 views

Take a list of ascii strings from a file and hash them using python threading

How can I do this in a more performant way? I'm concerned that throwing the data in a queue like this is defeating the purpose of yield from the ...
3
votes
0answers
46 views

Multithreaded OpenGL Rendering Pipeline

I've decided to move my rendering code to a separate thread, to help facilitate the move I've created a pipeline system for rendering. With this pipeline I can insert commands into a queue which will ...
6
votes
1answer
68 views

Worker pool implementation

With the new additions in c++11 and c++17 I wanted to create a simple implementation of thread pool. I would like your opinion on: Thread safety API performace and general code quality I also ...
1
vote
0answers
33 views

Temporarily block API calls when server sends a 503 response

I have a scenario in which I call many APIs throughout my application lifecycle. In case the server sends me a 503 response code, it will also send a lockdown object which has a timestamp associated ...
14
votes
3answers
2k views

Simple HTTP Server

I'm working on a project (studying) and I have a lot of time for proof of concepts and write something from scratch. Basically I'm creating an HTTP server (simple, but not too simple) in C++ using ...
1
vote
0answers
185 views

Simple Asynchronous Dispatch Queue

I'm practicing C++11/14/17 and am teaching myself the STL multithreading library by writing an asynchronous dispatch queue for my simple use case. It seems to "work ok" but I want to know if it's ...
1
vote
0answers
34 views

Java local service with sockets

My goal was to create a Java service on Windows that runs locally and communicates with local programs using JSON. The service should be reliable and robust. The service runs a ServerSocket and ...
2
votes
0answers
36 views

Comparing Java Semaphore versus ReentrantReadWriteLock

In this post, I attempted to compare the performance of two concurrency constructs: java.util.concurrent.Semaphore, ...
2
votes
0answers
174 views

C++ Producer / Consumer multi threads pattern with maximum container size

I've just written a Producer / Consumer pattern templatized that should work in multi threads environment (IE producer(s) and consumer(s) in separate threads). The original use case is one producer ...
6
votes
2answers
496 views

C++ parallel merge sort

I'm a first year computer engineering student who's learning about algorithms and data structures. I've implemented a parallel merge sort algorithm in C++ and would like constructive criticism. This ...
1
vote
0answers
21 views

Initializing and managing many references in multithreaded control application

I have a large multi-window GUI program (implemented with MFC) that controls a variety of physics experiment apparatus. When the user starts the main function of the program (the "experiment" run), a ...
2
votes
0answers
176 views

Many-readers-one-writer with semaphores and multithreading

I've been looking for a solution to the may readers one writer in Java. I was intrigued by this question posted here and I read the Wikipedia entry about it. So far, I've reached a fine solution, or ...
5
votes
0answers
88 views

A Parallel Processing Template for Divide & Conquer Problems

I’ve written a program for solving a problem using standard single-threaded code. However, it looks like it could be recast as a multi-threaded problem using divide & conquer. Since this is a ...
2
votes
2answers
100 views

C++ thread_pool with heterogeneous work-queue

I have read the book "C++ concurrency in action" and understood the thread_pool implementation. I have changed a few things according to my project requirements. I have used ...