Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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).

4
votes
0answers
15 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 ...
1
vote
0answers
32 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
49 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
8 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 ...
2
votes
1answer
38 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
20 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
58 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 ...
8
votes
2answers
181 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
76 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
21 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
57 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
175 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
40 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
42 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
41 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
65 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
29 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
71 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
34 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
133 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
411 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
20 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
142 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
84 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
88 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 ...
2
votes
1answer
49 views

Multithreaded local server

I'm writing several local servers which have almost the same code in main.cpp. Appreciate your comments, improvement suggestions and especially notes on potential ...
2
votes
0answers
197 views

Let Them Eat Lists, Eventually (Asynchronous Generic List Consumption with Spring and CompletableFuture)

I want to reduce some repeated code in my Java 1.8/Spring Boot application, and to that end I tried to make a reuseable asynchronous utility module. In essence its an async List.forEach that takes a ...
1
vote
1answer
57 views

Multithreading to allow multiple clients on to a server and client requests handling

I have to create a client-server JavaFX application using MVC which does many operations consisting mainly in messages exchange. I'd like to know if this way to handle client acceptance and client ...
4
votes
1answer
63 views

C++ observer pattern via boost.signals2

I was looking for a thread safe implementation of the observer pattern. I read https://xinhuang.github.io/posts/2015-02-11-how-a-multi-threaded-implementation-of-the-observer-pattern-can-fail.html and ...
0
votes
0answers
55 views

Is this the proper way to inform the main thread of an event from a Background thread?

The background-thread is an UDP listener. As soon as a certain type of message is received, the main thread has some work to do. My current solution works. But I'm in doubt of the implementation. My ...
3
votes
1answer
105 views

Golang HTTP requests

I'm beginning to learn about Golang and I would like to have some advice about the following program. ...
6
votes
1answer
197 views

C++ Pi Calculator - Leibniz Formula

Yesterday I saw a CodeTrain video in where Daniel Shiffman tried to approximate Pi using the Leibniz series. It was interesting so I decided to try it too. I wrote this console application with a ...
1
vote
1answer
163 views

Java concurrency exercise, implementing transfer of amount from one account to another

This is in continuation with my synchronized implementation of a bank account in Java. I am trying to implement bank accounts repository and method to transfer money from one account to another. My ...
7
votes
2answers
872 views

Synchronized implementation of a bank account in Java

I am trying to implement a bank account with Java in a thread safe way. My code looks like: ...
2
votes
0answers
236 views

Sending device data of 10k items with Parallel.ForEach

I have a deviceList of more than 10k items and want to send data by calling another method. I tried to use Parallel.Foreach but I'm not sure is this the correct ...
0
votes
0answers
22 views

Priority URL queue that does not block on put()

I am trying to build a priority queue that never blocks on put(), and discards the lowest priority item if it is full and user attempts to ...
3
votes
2answers
178 views

java Thread-safe LRUCache implementation

What is best way to implement thread-safe LRUCache in java? Please review this one. Is there any better approach which can be taken here? ...
0
votes
0answers
33 views

threaded event loop “interrupt” unit test without deadlocks

I have an event_loop implementation (basically an event/command queue and an exec function). I have added ...
0
votes
1answer
41 views

Stopping a running thread

I am trying to stop an executing runnable instance after the run method has been called. I have come up with the below approach ...
5
votes
1answer
347 views

Implementation of thread-safe vector

I have implemented a thread safe vector, based on std::thread and std::vector. I am new to many of the patterns used in threading and was wondering if there's a more efficient way the locking can be ...
1
vote
0answers
31 views

Socket sending/receiving data

I am a beginner in Android and this is my first big project in it. I am trying to communicate with an STM Discovery board using an ESP01 module. Below is the client connection class ...
0
votes
0answers
33 views

Mutex implementation using Windows APC

I just wrote this now and didn't test it much. This isn't a replacement for std::mutex, but for something like fun. I may develop it to make it shared across processes by storing the counters in a ...
1
vote
0answers
70 views

An attempt of replacing CRITICAL_SECTION with std::mutex and std::lock_guard

I have an older class that I am working on and I'm updating it to remove "Windows" specific code. It had some "Thread Protection Code" that used CRITICAL_SECTION. I'...
0
votes
0answers
45 views

Create a simple job system using a mutex-locked task queue

Although an experienced gameplay programmer, I'm relatively new to multithreading. I've attempted an implementation of a job system that my WIP 2D engine uses: it provides "engine" and "game" workers, ...