As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [concurrency]

In computer science, concurrency is a property of systems in which multiple computations can be performed in overlapping time periods. The computations may be executing on multiple cores in the same chip, preemptively time-shared threads on the same processor, or executed on physically separated processors.

Filter by
Sorted by
Tagged with
2 votes
1 answer
527 views

golang http.Client wrapper with rate and concurrency limiting

My goal is to safely consume an API without getting 429 Too Many Requests error, activating DDoS protection or going over system limit of maximum open file ...
beardeadclown's user avatar
0 votes
0 answers
141 views

Is my non-blocking collection actually thread-safe?

I've implemented this out of curiosity, and I'd like to know if I've implemented everything correctly, and/or see if anyone has suggestions. This caches some metadata for a game, so: Infrequent ...
Andrew Williamson's user avatar
1 vote
0 answers
66 views

"streaming" messages to a broker from a batch-like source (eg sql database), optionally acknowledge back to the source

I am writing library code to help other developers send messages to a pub-sub event broker. In many cases, the message source will not be "stream-like". Specifically, most messages are ...
allmhuran's user avatar
  • 111
3 votes
1 answer
222 views

Correct synchronization of reads and writes to ConcurrentHashMap and ConcurrentLinkedQueue

I am writing a web application (Servlets, JDBC, no Spring - for learning purposes) that accepts orders from customers, while registered couriers can choose which one of these orders they want to ...
Mike's user avatar
  • 31
2 votes
0 answers
43 views

Rust program to create mail.tm accounts

I have created a rust program to create https://mail.tm accounts, but I think there are things I could have done better. Are there things I can do to improve performance? Are there any unnecessary ...
cavalry1223's user avatar
1 vote
0 answers
830 views

Are nested calls to `asyncio.gather()` dangerous?

I wrote this ~100 line script recently, where I tried out Python's asyncio library. When it comes to asynchronous programming in Python, I just have 2 days of ...
Vikas Prasad's user avatar
2 votes
2 answers
490 views

Write deduplicated 9-digit numbers from concurrent clients to a log

Problem Statement: Write a server (“Application”) in Java that opens a socket and restricts input to at most 5 concurrent clients. Clients will connect to the Application and write any number of 9 ...
ProgrammingHandyman's user avatar
4 votes
0 answers
681 views

PyQt load images in background process

I am building an application that needs to load 100-200 images (really only limited by performance) and display them to the user in a sort of gallery. A good analogy would simply be Google Images. In ...
Spencer's user avatar
  • 261
4 votes
1 answer
100 views

Intersect channels in Go

I have a simple golang app in which I have two background tasks that produce data,each of them use it's own channel to signal it produced another unit of data. I have a single consumer that needs the ...
WildLAppers's user avatar
3 votes
2 answers
227 views

Generic concurrent bounded buffer in C

I just implemented a generic concurrent queue in C, and I'd like some feedback on my implementation, as well as the logic in handling generic data and concurrency. buffer.h ...
Samuele B.'s user avatar
2 votes
0 answers
212 views

Fixed-width non-FIFO DispatchQueue

I have implemented a custom concurrent queue on top of GCD which offers two additional pieces of functionality: Limit the maximum number of concurrently executing tasks. Give manual control over ...
Marcel Tesch's user avatar
4 votes
1 answer
248 views

A tiny threads pool in C

I'm a newbie in C, and currently following Stanford CS107 - Programming Paradigms. For assignment 6, I find it'd be better to isolate the threads management from the service logic. The following code ...
weiShen's user avatar
  • 205
5 votes
3 answers
882 views

Single Producer Single Consumer lockless ring buffer implementation

I am writing a simple ring buffer for my own education. Below is a crack at a strategy described in http://www.cse.cuhk.edu.hk/~pclee/www/pubs/ancs09poster.pdf : Producer and Consumer keep local ...
samwise's user avatar
  • 59
1 vote
0 answers
110 views

Parallelizing identical long-running tasks with Go channels

I have written a program in Go to compute the discrete logarithm mod primes (find \$x\$ such that \$h=g^x\mod p\$), and the algorithm I am using can be easily parallelized. Essentially, I am trying to ...
baum's user avatar
  • 123
2 votes
1 answer
134 views

Barging lock in Java

I found myself in need of a lock that allows my server to barge the write lock that might be acquired by my users. It would never interrupt them, but it would jump the line so the next time the write ...
corsiKa's user avatar
  • 660
2 votes
1 answer
868 views

Parallelized web crawler using goroutines and channels

As part of the "a tour of Go" section on golang.org, I was trying to make a (formerly singlethreaded) web crawler parallelized using goroutines. I got it working but it doesn't seem to "...
Snowbody's user avatar
  • 8,432
2 votes
1 answer
370 views

Thread-safe LFU Cache

I am trying to implement a thread-safe LFU cache algorithm, please review my code and would really appreciate some criticism or suggestion. (on naming, design, data structures used, anything) Some ...
yploo's user avatar
  • 31
1 vote
1 answer
1k views

Thread-safe LRU Cache Implementation in Java

I am trying to implement a thread-safe LRU cache algorithm, please review my code and would really appreciate some criticism or suggestion. Some assumptions: capacity will be larger than 0 Some ...
yploo's user avatar
  • 31
4 votes
1 answer
124 views

SHA256 password cracker - v2 with concurrency

I have updated my previous code with the suggestions. I have also implemented concurrency to speed up the results. I'd be interested for comments on a more efficient use on concurrency / parallel ...
EML's user avatar
  • 2,033
1 vote
1 answer
1k views

SO golang example with infinite for / channel workers

I whipped this up as an example of how infinite loops can often be used to great effect in golang, and also to discuss closing channels and worker communications. It was strictly off the cuff, but I ...
erik258's user avatar
  • 181
3 votes
1 answer
74 views

Waiting for goroutines to finish

I have a program that starts a bunch of goroutines, feeds them data and when there is no more data, waits for the goroutines to finish. I use sync.WaitGroup. I am unsure if I am using correctly, in an ...
RedGrittyBrick's user avatar
4 votes
1 answer
144 views

Speeding up I/O bound python program

I have the following program. I have 90 million domain names split between 87 files. I need to resolve the IP of all. Right now I feel like this is super slow. ...
Quesofat's user avatar
  • 143
4 votes
1 answer
76 views

A Concurrent Tree implementation with consistent snapshot capability

I have a tree in my application from which I need to periodically take a snapshot. I've been using locks so far, but after running into a few deadlock issues I decided to create a lock-free ...
Adam Arold's user avatar
6 votes
1 answer
191 views

Concurrent Web Crawler

Description As an exercise of learning go concurrency patterns, I decided too build a concurrent web crawler. I made use of the argparse module I put up for review a while back. I'm looking for ...
Ludisposed's user avatar
  • 11.5k
1 vote
1 answer
118 views

Concurrent dependant routines in a gui application [closed]

The idea is that, in my application I have 5 routines named long_process_1, long_process_2, ...
Ayxan Haqverdili's user avatar
2 votes
1 answer
76 views

Keep reading user keyboard input if available, while echoing back the latest available

On StackOverflow I have asked a question a few minutes ago, but then by trying a bit more, I found the answer myself, and I'm posting the resulting working code here for review. What the code does, is ...
Enlico's user avatar
  • 547
4 votes
0 answers
152 views

Game of Life, thread per cell

In an effort to learn Java's support for concurrency I solved a self-imposed exercise to write a Game of Life simulator in Java, running a separate thread for each cell. Here is my code: ...
gaazkam's user avatar
  • 571
4 votes
1 answer
581 views

A concurrent lock-free Linked Queue implementation

Recently I've been learning about concurrency/parallelism and I decided to implement the Michael&Scott lock-free Linked queue (PDF) as practice. I'm not entirely sure how to test this data ...
chromaticc's user avatar
3 votes
0 answers
339 views

Dining philosophers problem in Go

I'm new in Golang and haven't done concurrency in a bit. I would love to hear your opinion on my Dining problem Go solution. Description here, with a tl;dr below: Five silent philosophers sit at a ...
Levon's user avatar
  • 295
3 votes
0 answers
52 views

n executions of a periodic goroutine

I'm new to Go and have a use-case for periodically executing an async work-function. I want the interval between work-function executions to be constant (not the time between one finishing and the ...
geofflittle's user avatar
8 votes
0 answers
260 views

Implementing GSL synchronized_value

Core Guidelines mention a type synchronized_value<T>, which supposedly pairs std::mutex with the internal value. I couldn'...
Sergey Kolesnik's user avatar
2 votes
1 answer
52 views

Concurrency mechanism for ensuring repeated threads are executed in a given order

Inspired by the following leet-code Suppose you are given the following code: ...
Attilio's user avatar
  • 1,645
8 votes
1 answer
2k views

Reading one source Stream by multiple consumers asynchronously

The problem was using single Stream from the HTTP response in multiple consumers simultaneously. For example: while data is loading, I want write it to the some ...
aepot's user avatar
  • 1,989
1 vote
0 answers
48 views

Run non overlapped periodical tasks on user specified executor

I have concurrency tasks in my module: user code is able to instantiate my object and specify Executor service, then user can submit requests to this object which ...
g4s8's user avatar
  • 111
1 vote
1 answer
734 views

Concurrent Queue with enqueue and dequeue using Stack as underlying data structure

This is a mix of data structure and multi threading concept based question. (This is only for understanding and learning purpose) The language for the solution : Java A Queue with FIFO behavior needs ...
Krishna Kumar's user avatar
4 votes
1 answer
785 views

C++ latch implementation

Since std::latch is not in many standard C++ libraries, I tried implementing my own, is it OK from memory ordering perspective or ...
udslk's user avatar
  • 141
3 votes
1 answer
85 views

Command line dictionary tool, using webscraping

This is my first proper Go program, after completing Go by Example and https://tour.golang.org. I have a background in Python. This program scrapes definitions from Wordnik, then prints them nicely ...
makeworld's user avatar
  • 131
1 vote
0 answers
48 views

infinite generator with eviction

I made a struct that will loop through a list, and return the next element on calls to the Get() method. It also allows to remove elements from the list by calling the Evict() method, and is safe for ...
aguilbau's user avatar
1 vote
1 answer
2k views

Banking application - Optimizing java multi-threading code

I created a simple Bank application to make multiple transactions between multiple accounts. It is working as expected. But I want to know can I make the code more optimized. ...
Harsh Kanakhara's user avatar
4 votes
1 answer
511 views

One consumer and two producers using threads

I have based this code on Producer-Consumer Threading on Real Python. The idea is that I have 2 producers: One producer will give result every 0.4 to 0.7 seconds, depending on REST call. The second ...
WebOrCode's user avatar
  • 173
3 votes
2 answers
613 views

Simple multiple producer and single consumer concurrency pattern

Anyone please review and share your feedback for the following code. Multiple producers generate random integer numbers and a single consumer receives it to display only odd numbers out of it. ...
cslrnr's user avatar
  • 275
1 vote
1 answer
946 views

A multi-thread Producer Consumer, where a Consumer has multiple Producers (C++17) - Part 2

This post is based on A multi-thread Producer Consumer, where a Consumer has multiple Producers (C++17). I am trying to build a Consumer that consumes data from ...
User12547645's user avatar
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. ...
User12547645's user avatar
11 votes
2 answers
4k views

Multi Threaded High Performance txt file parsing

EDIT A port of Björn's answer to C++ with further improvements at bottom achieving up to 2.4GB/s on the reference machine. Text file parsing and processing continues to be a common task. Often it's ...
Oliver Schönrock's user avatar
3 votes
0 answers
4k views

Hosted service for queuing and running tasks in parallel in ASP.NET Core

I am attempting to construct a background service for an IIS-hosted ASP.NET Core project that basically queues tasks and runs them, and I decided to go with the ...
Bryder's user avatar
  • 139
2 votes
2 answers
327 views

Recursive Mergesort using goroutines

When learning a new language, one of my first tasks I like to go through is writing a few different sorting algorithms in that language to help familiarize myself with the syntax and see if there are ...
c4llmeco4ch's user avatar
1 vote
1 answer
2k views

Thread Safe Bank Transaction: Deposit, Withdrawal, Check Balance and Transfer in Java

I have made a class which is a thread-safe implementation supporting Deposit, Withdrawal, Check Balance Querying and Transferring of money. I have a class Account: ...
Jim's user avatar
  • 21
3 votes
1 answer
164 views

Code to print even and Odd number using two threads

Below I am giving you my code which I wrote to print even number using even thread and odd number using odd thread sequentially. Could anyone please validate my code whether it is correct way of ...
Arghya Pal's user avatar
2 votes
1 answer
88 views

Concurrency-safe task scheduler

I'm trying to do some task scheduler and worker. Tasks are added to the queue from which worker retrieves and processes them. Tasks from one queue must be executed sequentially. Tasks from different ...
buildok's user avatar
  • 123
3 votes
1 answer
5k views

Simple Producer-consumer implementation in Python

I implemented a simple solution to the Producer–consumer problem that I'd love for you to take a look at. The producer simply adds random numbers to a queue and the consumer (from a separate thread) ...
michaelrbock's user avatar

1
2
3 4 5
10