Questions tagged [multithreading]
Use this tag when the program performs its work using multiple concurrent threads of execution.
151
questions
10
votes
0
answers
706
views
Sieve32FastV2 - A fast parallel Sieve of Eratosthenes
I’ve created a much cleaner, better designed version to my parallel sieve. I’ve implemented most of EBrown’s micro-optimizations but also revamped the code on my own (that is not in direct response ...
15
votes
1
answer
8k
views
A simple Thread Pool
A very simple Thread pool:
Any work added to the pool will be executed. The destructor will wait for all work to be finished before letting the threads stop. We then join all threads before letting ...
40
votes
3
answers
11k
views
Exporting doc types using queues and multithreading
For a while I have been interested in seeing if some tasks work well when split across multiple threads.
On the one project I have been busy with I have been creating a lot of small utility apps, to ...
15
votes
4
answers
2k
views
Multithreaded Mandelbrot Generator
I built one of these long ago, and it got lost when I reformatted my SSD (sad day) so here is the new version.
It is very multithreaded, spawning numCores - 1 ...
5
votes
1
answer
134
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
0
answers
2k
views
Android APP connect to FTP server in Java
I am attempting to build an Android APP with the ability to connect specified FTP server in Java. The connection operation has been performed in FTPconnection class ...
3
votes
2
answers
1k
views
Platform independant thread pool v2
This is a continuation of this question, v3 can be found here
Taking into account the advise given by Loki, an implementation of the threadpool using a ...
150
votes
17
answers
19k
views
Disproving Euler proposition by brute force in C
I wrote a little bit of code to brute force disprove the Euler proposition that states:
$$a^4 + b^4 + c^4 = d^4$$
has no solution when \$a\$, \$b\$, \$c\$, \$d\$ are positive integers.
I'm no ...
13
votes
3
answers
2k
views
Parallel sieve of Eratosthenes, version 2
This question is a revision of Parallel sieve of Eratosthenes. The goal is to implement a sieve of Eratosthenes with parallel strikes out from the boolean array. I tried to fix the data races and all ...
12
votes
2
answers
10k
views
Efficiently using Apache HttpClient in multithreaded environment
I have a library which is being used by customers and they are passing DataRequest object which has userid, various ...
11
votes
3
answers
657
views
Multithreaded Mandelbrot Generator Ver 2
Update: Version 3 is here.
My first version was an answer I provided to EBrown for his original post titled "Multithreaded Mandelbrot Generator". My answer had many good things in it, but I felt ...
10
votes
1
answer
2k
views
Sieve32Fast - A very fast, memory efficient, multi-threaded Sieve of Eratosthenes
An improved version Sieve32FastV2 is available.
The classical solutions for the Sieve of Eratosthenes fall into 2 camps: one uses a bool[], which is fast but very ...
8
votes
3
answers
381
views
Having full atomicity against all the threads without impacting performance or throughputs
I am working on a project in which I construct a URL with a valid hostname (but not a blocked hostname) and then execute that URL using RestTemplate from my main ...
7
votes
2
answers
1k
views
Lock for preventing concurrent access in client data
I am trying to implement lock by which I don't want to have reads from happening whenever I am doing a write.
Here is my ClientData class in which I am using ...
6
votes
3
answers
3k
views
A multi-thread Producer Consumer, where a Consumer has multiple Producers (C++17)
EDID: Thank you very much for your feedback. I updated the code and opened a new post for the updated version. See here.
This post is loosely based on A multi-threaded Producer Consumer with C++11.
...
6
votes
2
answers
3k
views
Producer/Consumer implementation
I am using Netty embedded within Grails to process and display incoming SNMP messages. Since Netty 4 doesn't come with a built-in ChannelExecutionHandler I had to ...
5
votes
2
answers
486
views
Multi-threaded domain status checking in Java
I'm tinkering with the idea of crafting a search engine in my spare time. More of a learning experience than anything at this point, but still a project. A key aspect of this system is checking ...
5
votes
2
answers
3k
views
C++20 Thread Pool
I've implemented a thread pool using C++20. I'm fairly new to concurrently/multi-threaded programming and wanted to work on a project that I could learn from while also getting to know some of the new ...
5
votes
1
answer
2k
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 ...
3
votes
2
answers
486
views
C++11 ThreadPool implementation
A new version of this code based on the provided advice can be found here.
Latest improvement is found here.
I made a simple ThreadPool implementation in C++ using ...
3
votes
2
answers
295
views
C++ ThreadGroup Implementation
Edit: An improved code based on feedback is available here.
As a kind of sequel to the previous question, here is an improved version( with clarified naming ). The Idea is the same: An integer ...
2
votes
1
answer
1k
views
Producer-Consumer in C++ - follow-up
To expand from the changes supplied by the answer of my previous question:
...
1
vote
1
answer
108
views
C++ Improved ThreadGroup Implementation
After the amazing feedback from these questions; I have prepared a third version of the original posted code.
The Idea is the same: An std::size_t variable ...
43
votes
5
answers
7k
views
Parallel sieve of Eratosthenes
For the first time, I tried to use threads by myself in order to implement a parallel sieve of Eratosthenes. The trick is that each time a prime is found, a thread is spawned to eliminate all the ...
40
votes
1
answer
4k
views
Recursive shared_mutex implementation
I found myself in need of a Readers-Writer mutex. With C++17 TR2 support not yet available in our compiler, I set out to implement std::shared_mutex so that we have ...
27
votes
3
answers
4k
views
Network chat app
Applying a lot of unprecedented concepts here, it's a simple chat server capable of handling multiple clients, which are run through JavaFX, and have their individual threads instantiated and handled ...
22
votes
5
answers
36k
views
A TaskScheduler that always run tasks in a specific thread
The following is an TaskScheduler that always run tasks in a thread it maintains.
When created, a name of the thread was specified. Once you schedule the first task,...
18
votes
2
answers
28k
views
Portable periodic/one-shot timer implementation
Note: I have posted a follow-up question for a significantly updated version of this code.
I have implemented a class that provides portable one-shot or periodic timers.
The API provides a way to ...
18
votes
3
answers
5k
views
Producer/Consumer programs
I am studying mutual exclusion in college, and we just covered the producer/consumer problem. The class does not involve writing code, but I decided to implement a bounded buffer version of this ...
17
votes
2
answers
6k
views
Lock-free zero-copy triple buffer
In a producer-consumer scenario sometimes we have to deal with the producer being much faster than consumer. The data loss is unavoidable, and we are OK with it, as long as the consumer always has the ...
15
votes
3
answers
3k
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 ...
14
votes
2
answers
8k
views
Parallel Merge Sort
Parallism is achieved by using a simple call to tbb::parallel_invoke(). However I can't break a speedup factor of x2 (after ~3-4 parallel HW threads), although 8 ...
12
votes
2
answers
2k
views
Implementation of a lock-free fixed-sized allocator
This question now has a follow-up:
Implementation of a lock-free fixed-sized allocator - follow-up - with commented code
I've tried implementing a lock-free fixed-size allocator while trying to ...
11
votes
1
answer
2k
views
Do not share same socket between two threads at the same time
I have a code in which I am dealing with sockets and I need to make sure that I don't share same socket between two threads. In my below code, I have a background thread which runs every 60 seconds ...
11
votes
4
answers
13k
views
Clean and well-designed Tic-Tac-Toe game
My design goal was to try and make a "clean" and well-designed Tic-Tac-Toe game but also to try and use concepts and programming constructs that I'm new to.
I'm planning to implement an "AI Player" ...
11
votes
3
answers
11k
views
Thread pausing/resuming/canceling with Qt
I have written this code to be able to suspend (or to cancel) a worker executed in a separate thread in Qt.
To do it, I have used an instance QWaitCondition and <...
11
votes
2
answers
2k
views
Command line IRC client
I made this IRC client ages ago in Python, and thought I'd revisit it for Python 3.5 (I'd like to play with asyncio). Before I start, I'd like to have an overall design review about this.
Known ...
11
votes
1
answer
7k
views
Timer to poll a Delegate
This is a followup to this where I was initially using a single thread and Thread.Sleep() to poll a delegate. I was recommended to use a timer and the ...
10
votes
1
answer
51k
views
Java multi-thread file server and client
My task was to build a multi-thread file server and a client that can upload or download a named file over sockets. It is assumed that the client will finish after its operation and there is no need ...
10
votes
1
answer
1k
views
Follow-up: Timer utilizing std::future
The previous code (as displayed in Timer utilizing std::future) is now:
...
10
votes
2
answers
30k
views
Synchronous and asynchronous behavior for client
I am working on a project in which I am supposed to make synchronous and asynchronous behavior of my client.
The customer will call our client with a userId and we ...
10
votes
1
answer
53k
views
Writing to file in a thread safe manner
I'm writing Stringbuilder to file asynchronously. This code takes control of a file, writes a stream to it and releases it. It deals with requests from asynchronous operations, which may come in at ...
10
votes
1
answer
2k
views
Platform independant thread pool
v2 of this question is here and v3 is here
To get a better understanding of C++11/C++14, I thought I would develop a thread pool, even if it has been done to death!
The only dependency outside of ...
9
votes
2
answers
9k
views
Python Port Scanner
This is only my third Python script. Be brutal with me. Any tips, tricks, best practices, or better usages would be great!
...
9
votes
2
answers
2k
views
Concurrent FIFO in C++11
I have implemented a simple FIFO that can optionally be used by either a single thread or way to pass data between threads. The class is templated with arguments for the types the queue will contain ...
9
votes
3
answers
2k
views
Naive lock free work stealing queue
Recently, I read a article about work stealing queue Job System 2.0: Lock-Free Work Stealing – Part 3: Going lock-free, and this is my c++11 naive implementation based on my understand of c++11 ...
9
votes
3
answers
2k
views
Platform independant thread pool v4
This is a continuation of this question.
Following the previous advise, the thread pool now can handle almost all types of input, except for one key form, where the function/functor requires one of ...
8
votes
1
answer
5k
views
Generic Java task-scheduler
I wrote this generic task scheduler for executing tasks in fixed-delay intervals. Can you find anything wrong with it, or issues that may arise from using it for sending something like queued mails in ...
8
votes
2
answers
3k
views
Portable periodic/one-shot timer thread - follow-up
This is a much improved version (I hope) of code in this previous code review of mine.
I have:
renamed several things. Are the names good?
made it lazily start the worker thread only after the first ...
8
votes
2
answers
4k
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:
...