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

3
votes
2answers
38 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
96 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
0answers
24 views

Uploading records into S3 using multi-threaded application

I am trying to upload huge numbers of files from a folder where files are keeps on coming . The rate at which files are coming is approx 15K per minutes . I have written my code utilizing multi-...
0
votes
1answer
29 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
34 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
40 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
99 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
24 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
93 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
22 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
117 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
135 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
41 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
51 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
33 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
55 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
48 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
40 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 ...
1
vote
0answers
43 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
431 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
52 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
27 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
104 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
88 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
157 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
72 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 ...
0
votes
0answers
102 views

C++20 multithread pool class

This is an iteration from a prior post; C++ multithread pool class. Class for creating thread pools with upcoming C++20 standard (-std=gnu++2a -fconcepts). It ...
2
votes
1answer
373 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
82 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). ...
0
votes
0answers
60 views

Is this the right way to implement multithreading

I need to write a series of console applications (about 20 of them!). I want each app to be as consistent as possible with regards how it starts up and shuts down, maybe with the logging it generates ...
-1
votes
1answer
182 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
128 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 ...
-1
votes
1answer
56 views

Java Multi-threaded Chat Room

In an attempt to learn more with Java, I decided to challenge myself by creating a GUI-based, multi-threaded chat room. Currently, you run the Client and it prompts you to either create or join a ...
5
votes
1answer
168 views

Snowflake Id implementation

For some time now I have maintained (and written) IdGen. It's inspired by Twitter's Snowflake project and it's intended use is to generate (roughly) incremental id's in a distributed scenario with ...
4
votes
1answer
162 views

Simple Java Download Manager

I have written a simple download accelerator in java which downloads the same file in multiple threads and then combines them all. I would love some feedback on my design. How the same implementation ...
-1
votes
1answer
44 views

Serializable game loop thread

I have been working on a small game lately and I was tired of looking up and copy-pasting game loops so I tried to make one as you can see. It works perfectly so if you want to feel free to use it, ...
2
votes
1answer
106 views

Are numbers prime multithreading

I'm trying to learn some multithreading and this seems like a good example, want to apply this to frustum culling later. The goal is to find prime numbers in randomly generated vector of numbers. ...
1
vote
0answers
49 views

Making multiple HTTP requests to Twitter

I need to make multiple http requests very fast. I've currently use this method. ...
5
votes
1answer
126 views

C++ thread pool class

I have addressed the critique for this post and resubmitted it for iterative review; C++ multithread pool class. Class for creating thread pools with the latest C++ standard. Currently C++17 and C++...
3
votes
2answers
76 views

C++ workqueue class

This is a nice workqueue class template to keep the gui fluid, while data is being written into a database or into some file/network... ...
9
votes
1answer
480 views

A thread-safe priority queue keeping its elements unique

This class is intended to be used in situations where queue.Queue does not suffice, because the following two properties are needed. Every item in the queue can ...
-1
votes
1answer
54 views

Executor tasks for parallelizing a method [closed]

So I am trying to delete a list having n number of objects and thereby I divided the list in 4 parts and let it to be deleted in parallel. The intention here is to do it in parallel so as to make it ...
5
votes
3answers
283 views

DNA reverse complement as fast as possible

This code is meant to compute the reverse complement for a given sequence of bases. The code is tested versus some test cases and seems to work so far. The primary goal is that it should be as fast ...
4
votes
1answer
97 views

A thread safe task queue implementation using my own lock_guard in C++

As an exercise in multithreaded programming, I am trying to implement a basic FIFO task queue. For this, I also implement simplified version of my lock_guard, from ...
11
votes
3answers
2k views

Multithread to print odd and even numbers

I recently started on C++ multithreading. Here is my code to print odd and even numbers in two different thread. Can somebody please review this code? ...
3
votes
1answer
51 views

Java Concurrent Recursive API Access

I don't get to write multithreaded applications very often, so be gentle with my threads :-) I have an API input which contains a "score" and then a bunch of child nodes which also have scores, and ...
3
votes
1answer
80 views

Simple dirbuster with threading

I've made a simple dirbuster. (I wanted to play with threading.) The program makes requests to fuzz for files and/or directories on a site. Featuring fuzzing for response codes fuzzing for files ...
3
votes
1answer
78 views

Multi-threaded tree search

This is my first nontrivial multi-threaded program. It recursively searches through a tree (haystack) to find the leaf where ...
6
votes
1answer
115 views

Generic Producer-Consumer in C++11

I wrote the following simple 1 producer - 1 consumer problem, in attempt to learn some C++11 threading / generics. ...