Stack Exchange Network

Stack Exchange network consists of 174 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).

1
vote
2answers
40 views

Mutex Protected Object (scoped object wrapper)

This is a class that holds mutex and associated object. On checkout/access the mutex is locked while the stack object lives and a reference to object is obtained. Any suggestions or improvements is ...
0
votes
0answers
33 views

Split data equally to Thread in java

Is this efficient way to split the record which is comes from database? So that the thread will process the record based on the start and end points. Step 1: Get the total number of records from ...
0
votes
1answer
44 views

MQTT Client that send, receive and process mqtt messages

I'm setting up a python mqtt client that is supposed to receive messages of specific topics, process the messages when all incoming messages from the clients are complete, output the new calculated ...
3
votes
1answer
114 views

Sanity check for Simple Threading library

I've created a library providing a ThreadBlock that has the following features: Aggregates results of all actions executed Provides for non-threaded warm up to ...
5
votes
2answers
96 views

Using two threads to increase RFC1951 Deflate compression performance

I have modified my implementation of RFC 1951 "Deflate" compression to use two threads. One thread performs the LZ77 matching, looking for sequences of at least three bytes that occur earlier in the ...
1
vote
1answer
79 views

Receiving and sending notifications from database

I'm not much familiar with Task Api programming in C#. Can anyone review my following code? The following is a ElapsedEventHandler of a ...
2
votes
1answer
41 views

Sharing data with another thread using lock_guard

I wrote a updater_thread() and a reader_thread(), and used lock_guard to protect a global ...
1
vote
0answers
28 views

Applying Observer-Observable pattern to a code and multithreading

I have to: 1) Apply the Observer-Observable pattern to the original code. 2) starting from the original code, I have to suppose that the modification of the array fields (slot machine numbers) ...
0
votes
0answers
37 views

Inter Thread communication between n thread

The following program takes 3 integer inputs(noOfThreadToBeCreate,fromNo,toNo) and print the Consecutive numbers based on the range using different threads e.g (Thread 1 - Print 1, Thread 2 - print 2, ...
-1
votes
1answer
65 views

Waking up a thread while sleeping [closed]

I have a thread which periodically executes a task. Something like the following: ...
2
votes
0answers
35 views

Thread-safe sensor interface with observer and strategy patterns

I have a thread-safe API for an observable Sensor. The concrete type of the Sensor is chosen in the ...
1
vote
1answer
45 views

Processing a company list in which every element is an employee list

Now, there is a company list in which an element is an employee list in every company. I calculate the salary of employees in every company with a RESTful API one by one,. This is very slow, so I join ...
1
vote
0answers
64 views

Image capture client - multi-threading + sharing data between services

I'm working on a small side project at the moment - like a homemade CCTV system. This part is my Python Capture Client - it uses OpenCV to capture frames from a connected webcam and sends the frames ...
2
votes
0answers
46 views

thread safe queue with interrupt function

I try to implement a thread safe queue with the interrupt function (interrupt all threads who are blocking to take data from queue). ...
1
vote
0answers
20 views

A syslog to Azure Log Analytics forwarder

I am using this code to forward my syslog logs (converted to json using syslog-ng) to Azure Log Analytics on an ARM board (since there is no official client for ARM)...
0
votes
1answer
89 views

Generating parallel random numbers in a thread-safe way and using them in computations implemented by class method [closed]

I have the following code that I managed to make thread-safe but I am not sure if I am using C++ technology optimally. ...
2
votes
1answer
56 views

Java League of Legends ping checker

I'm still a freshman and this one of my first projects I made using Java and Swing. The program is a simple League of Legends multi-threaded ping checker that pings the server 10 times to get an ...
4
votes
1answer
166 views

Concurrent observable collection

I'm working on a WPF 4.5 desktop application that has several nested collections with the following key aspects: writes mainly from UI thread, but also from worker threads writes are relatively ...
1
vote
1answer
42 views

Simple multithreading C project

I'm fairly new to C, and this is my first time using pthread. I am pretty sure I implemented it correctly, however I'd like to verify it is indeed executing the ...
3
votes
0answers
49 views

Using Python threads to download images

I am using Python threads to download images. I have a JSON file that contains URLs to the images in the following structure: ...
3
votes
2answers
44 views

Python 3 multi-threaded pinger

My goal: I want to ping every single IPv4 address and record whether or not they responded. The way I have it set up is every IP address corresponds to an index. For example ...
5
votes
1answer
109 views

Requesting 400 links with multithreading and ThreadPool

I am working on multi-threading application to learn multithreading better. My application has a queue with 400 unique links, 4 threads and each thread is pulling link from the queue and sending a Get ...
0
votes
1answer
34 views

Multi threading with CachedThreadPool [closed]

I have server-client communication architecture where there is one server and 150 clients. The server-client communication happens via Java NIO where all the clients send some or the other data every ...
2
votes
0answers
40 views

Conditional AsyncLock implementation

I have a case where I match data from DB by the various filters. Until the match is updated in the DB, I don't want to accept requests for matching with the same criteria, as this could produce ...
3
votes
0answers
52 views

Linked list with hand-over-hand locking

Follow-up to this question: after reading the comments, I decided to redesign my linked list to have a cursor that only contains one node and implement the interface similar to the one of forward_list ...
4
votes
3answers
107 views

Really easy synchronised access to an IEnumerable without boilerplate code

Often when reading data from a sequence (IEnumerable<T>) in multi-threaded code, a consistent snapshot needs to be taken inside a ...
3
votes
0answers
40 views

Perl PasteBin scraper

I'd like to optimize my code and get a better of understanding of how I can perform the task I am doing better. I've only used Perl threads about 3 or 4 times now. The purpose of my script / code ...
5
votes
1answer
104 views

Linked list node-level locking

I am new to C++ threading library. I would love to get some comments on how to improve this code (if there are possible bugs, I would appreciate that feedback too). In particular, I want to refactor ...
1
vote
0answers
36 views

Multithreaded FRC Robot Framework (Kinda Big)

I'm working on some code for an FRC Robot. I wanted to see if there's any obvious improvements that can be made here, that stands out, or stuff I should avoid doing. This is a test bed for the base ...
7
votes
1answer
132 views

Threadsafe oneshot-event which fires on subscription if the event was fired in the past

Assumptions Basically, a Connection class has a "Disconnect" event. Subscribing to this event isn't thread-safe, because the disconnection may fire from another thread right before I subscribe. So ...
4
votes
2answers
144 views

Using lock with value type (multithread context)

I have to use value type to lock code sections in correspondence to objects identifiers (i.e. Guid, int, ...
1
vote
1answer
43 views

Enforce printing sequence using wait() and notify()

This is a follow-up answer "implementation" to a question I posted on SO. For the sake of convenience, I will repeat my intent: I want one thread (called sub-thread) to print 10 times under outer-loop ...
3
votes
0answers
55 views

Override prototype inside of constructor of ES6 class for dependency injection

We implemented a small dependency injection mechanism which we use in our project. Now after 2 years of developing our project we need our classes to know who instantiated them via dependency ...
0
votes
1answer
37 views

Inter Thread Communication Even Odd Example

I have implemented a simple example for inter thread communication which have 2 threads to print even and odd numbers in sequence. I am looking for a feedback and points for improving the example. ...
1
vote
1answer
80 views

Producer consumer design and implementation using Java 8

Please review my design and code implementation and suggest if any optimisation is possible in terms of performance (time complexity / space complexity ) or any better way of design or implementation. ...
3
votes
2answers
51 views

Special FileLogger: write-all after 100 logs or before 1 second without new log

My question is about an easy FileLogger. I want the FileLoggers to store new logs in a collection, and write them in a file only if: - There are 100 logs if the collection - It's been more than 1 ...
2
votes
0answers
45 views

Monadic implementation of asynchronous tasks (hidden overhead of threads)

So, I've been reading about monads and I wanted to see if I could implement a system for asynchronous computation in a monadic way. I came up with two solutions: The first one spawns a thread for ...
2
votes
0answers
165 views

Better way to set number of threads used by NumPy

Background When NumPy is linked against multithreaded implementations of BLAS (like MKL or OpenBLAS), the computationally intensive parts of a program run on multiple cores (sometimes all cores) ...
4
votes
2answers
529 views

Concurrent quicksort in C++

I have a task to write a concurrent version of quicksort algorithm, to speed it up. This is what I wrote: ...
1
vote
1answer
96 views

Rust Task Queue

The purpose of this program is to have one thread (main thread) working on I/O reading lines from a file and feeding it to a pool of worker threads whose job is to perform some processing on each line ...
2
votes
0answers
34 views

Comparing performance of multi- and single - thread search of a maximum number

I have a class that compares the performance of two methods (multi- and single- thread) that searches for maximum number in the string of numbers. I want to improve the performance of a multithreaded ...
3
votes
0answers
30 views

Architecture for a parsing tool

PostgreSQL, Python 3.5, SQLAlchemy I have a main database which has a journals table containing 30k+ journals. For each journal I have a RSS feed URL, using which I can parse and get new articles. ...
0
votes
1answer
327 views

Print odd and even numbers using two threads in Java

I was asked below question in an interview where I need to print out even and odd numbers using two threads so I came up with below code one without synchronization and other with synchronization. <...
5
votes
1answer
130 views

Single producer single consumer wait-free object container

I have a fast producer thread and a slow consumer thread. The consumer processes as many objects as it can and simply ignores the rest in order to not slow down the producer. Therefore, I used a one-...
3
votes
3answers
181 views

C++ upgradable RW lock implementation

I am using VS 2017 with C++ 17 standard set on Windows OS. What I'm missing in couple of heavily threaded projects is synchronizing mechanism that can be atomically upgraded from shared to exclusive ...
3
votes
1answer
75 views

Monitor asynchronous tasks, tracking their running times

Scenario: I'm getting requests through a (thread-safe) queue. Each request then needs to be handled in a separate thread. There is a chance that the function (which is actually calling a Java-program ...
2
votes
1answer
381 views

C++ multithread pool class

I have addressed the critique for this post and resubmitted it for iterative review; C++20 multithread pool class. This is an iteration from a prior post; C++ thread pool class. Class for creating ...
1
vote
0answers
145 views

Using multi-threading efficiently with million GET requests

Disclaimer: The following question is not related to any malicious activity. Only performance testing we are doing. I am working on querying an internal server with lots of requests (~20 million). ...
-1
votes
1answer
255 views

Thread-safe queue mechanism

Is it my queue mechanism thread safe? I just wonder if I need concurrent collections. Need I lock Enqueue method? Console displays queue count in incorrect order, Does it affect on maxQueueCount at ...
4
votes
0answers
214 views

Custom TaskScheduler: Limited concurrency level

I'm interested in some feedback for a custom TaskScheduler implementation I wrote today for use on a game server - I wanted to be able to have a single-threaded scheduler for tasks since the game is ...