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
2k views

Java Concurrent Multimap

I've implemented a concurrent multimap that support concurrent put and remove but I'm unsure of its correctness. I would appreciate your feedback. ...
Elad Tolochinsky's user avatar
3 votes
1 answer
165 views

TimeoutManager: check whether a task has been finished within a given time

I want to make a helper class, which raises an event whenever something is not finished in a certain time. Example: my program sends out multiple network messages concurrently. After a random delay, ...
HugoRune's user avatar
  • 339
4 votes
2 answers
686 views

Pausing and resuming a concurrent database update queue

I have a class DatabaseQueue which asynchronously runs SQLite updates that it takes from a LinkedBlockingQueue. I implemented a ...
kmecpp's user avatar
  • 143
3 votes
0 answers
114 views

Concurrency using immutability

I was watching the following video about software transactional memory(using a package that maintains an access log). At the moment I am trying to learn about concurrency with shared memory and ...
HMR's user avatar
  • 139
5 votes
2 answers
588 views

Thread-safe BitArray

Notes: supports 64-bit platforms only ulong used where negative values make no sense library functions are assumed to be correct (whether they actually do what I ...
Kittoes0124's user avatar
  • 1,870
9 votes
1 answer
1k views

Dynamically extensible threadpool implementation in C

Purpose For my recent project, I needed a thread pool. I saw a lot of implementations at GitHub, but most of them were quite complicated. With complication comes performance penalty. Most importantly,...
Subhranil's user avatar
  • 191
6 votes
1 answer
2k views

Thread safe ConcurrentDictionary wrapper

I needed some features that ConcurrentDictionary doesn't have (such as a maximum number of items) so I created a wrapper around it. This is my first time working ...
Matthew Faigan's user avatar
1 vote
0 answers
195 views

Answering Master Clojure for the Brave and True - concurrency exercises

I recently answered the two exercises at the end of this chapter of Clojure for the Brave and True (see the end of the page). First exercise: count words in random quotes (in parallel) This is my ...
MMacphail's user avatar
  • 131
2 votes
1 answer
4k views

Limiting the maximum amount of goroutines run simultaneously

Here is my code which helps me to contol the maximum amount of goroutines run simultaneously. In example below maximum is 5. ...
Dmitriy.Sh.'s user avatar
3 votes
2 answers
750 views

HackerRank challenge to count ways to climb a staircase, solved using Java Fork Join

I'm trying to solve Stair case recursion problem on HackerRank. The problem is to find all possible ways for a child to climb a stair case with height n given that ...
LifeJoint's user avatar
  • 133
3 votes
2 answers
513 views

ConcurrentHashQueue in C#

The ConcurrentHashQueue data structure is a FIFO queue that at the same time allows look-ups of items based on a key in O(1) like a dictionary. It can be used as a ...
Dejan's user avatar
  • 143
3 votes
1 answer
2k views

Work stealing queue

I implemented work stealing queue inspired by Sean Parent's talk on code::dive 2016. Full implementation is here. I am looking to get feedback on improvements to make code more effective and common ...
Viktor's user avatar
  • 143
5 votes
2 answers
1k views

Golang concurrent writer

I wrote a program that concurrently reads multiple files and makes a request to an API for each line of each file. The JSON response is then parsed and the "available_filters" field is extracted. The ...
Dante's user avatar
  • 153
0 votes
1 answer
2k views

Sum and stock size concurrent code using Executor

The code should parse the input values and calculate the sum and size of particular stocks, using Executor thread pool by dynamically adding the thread count. Please review the following code for ...
bhadram's user avatar
  • 109
2 votes
0 answers
198 views

Using blocking queue to calculate data stream - Generalized

A followup on my previous question Using blocking queue to calculate data stream. This time suppose we have a list of blocking queues as stated in the following manner: Suppose you have a list of ...
zokland's user avatar
  • 95
1 vote
1 answer
702 views

Find pairs of consecutive numbers fetched from blocking queues

I was coding for the following programming question: Suppose you have two independent blocking queues that will keep getting new data, the new data will always be greater than the last element of ...
zokland's user avatar
  • 95
4 votes
3 answers
5k views

Matrix multiplication with OpenMP parallel for loop

I tried implementing matrix multiplication with parallel for loop in OpenMP as follows. It runs correctly but I want to make sure if I'm missing anything. How does this determine the number of threads ...
SachiDangalla's user avatar
5 votes
2 answers
1k views

Concurrency-safe stack implementation in Go

As Go doesn't come with a lot of collection structures, I've implemented stacks myself, building off some sample code I found floating around. I've then tried to extend it further by: Making a "...
Leylandski's user avatar
5 votes
1 answer
61 views

Recur-ratively resolve dependencies and summarize all results

I've been tasked with resolving all dependencies to a project. Because it couldn't be simple (it never is, right?), the requirements include a few different dependency management tools. For a first ...
Vogel612's user avatar
  • 25.2k
4 votes
2 answers
225 views

Task Wrappers for starting operation only if previous task has finished

I've written these two wrappers around Tasks, to help with common scenarios in our code where methods are called repeatedly, even if the previous operation hasn't completed yet. There are two common ...
Avner Shahar-Kashtan's user avatar
4 votes
1 answer
3k views

Blocking queue implementation with std::unique_ptr

I implemented, somewhat closely based on this implementation, a blocking queue with emphasis on filling up first. So if one producer and one consumer thread are using the queue, the producing queue ...
Jonas K's user avatar
  • 43
3 votes
0 answers
755 views

Implementing non-blocking Executor.map

I wanted to extend concurrent.futures.Executor to make the map method non-blocking. It seems to work fine, but I would be very ...
max's user avatar
  • 205
8 votes
3 answers
2k views

The dumbest (futex-based) mutex

After reading Ulrich Drepper's "Futexes are Tricky", I have written the following "dumbest mutex" in C++14 using the Linux futex primitives. This mutex is simpler ...
Quuxplusone's user avatar
  • 19.2k
3 votes
1 answer
912 views

Producer - multiple consumer implementation using futures

I've tried to implement a producer-multiple consumer pattern using futures and I was wondering should it ever deadlock, and if it should, why? I have this method ...
Marin's user avatar
  • 133
6 votes
3 answers
780 views

Delegating ExecutorService implementation requiring only an Executor

I occasionally find myself needing to run code on some arbitrary thread or pass a Runnable to some arbitrary consumer, and missing the full functionality of java.util.concurrent -- for instance, ...
David Moles's user avatar
1 vote
1 answer
1k views

Polling an API endpoint with timeout using channels

I have written a simple API client for my app in Go. The client is very simple, it wraps http.Client and has some convenience methods. The one method I am trying to get some feedback on, does ...
zam6ak's user avatar
  • 781
2 votes
1 answer
161 views

Thread-safety based on object value

I need to create thread-safety on a Web-API method, but only when two requests containing the same property value are ran simultaneously. I have created a mix of WaitHandles and a ...
Steven Ryssaert's user avatar
5 votes
1 answer
7k views

Java Matrix multiplication using Multithreading

I am trying to achieve matrix multiplication using the concept of concurrency and cyclic barrier. Here is the code snippet:- ...
Ap00rv's user avatar
  • 53
3 votes
1 answer
4k views

Send multiple broadcast to multiple listeners

I want to send multiple broadcast to multiple listeners in go. I can't send data through a channel, because only one listener will get it, except for the close ...
oliverpool's user avatar
  • 1,902
3 votes
0 answers
178 views

Concurrent AWS S3 copying of images listed in MySQL

I created the following one off script and it did the task quite well (1000s of requests / second with low CPU usage - outperformed the previous python script in every aspect). But I am wondering if ...
Georg Buske's user avatar
3 votes
1 answer
52 views

Call third parties in parallel

I am trying to speed up some reporting on all employees but I am having difficulty determining where the "proper" place to parallelize my tasks. In order, this is what my code is currently doing. Ask ...
Michael's user avatar
  • 133
5 votes
1 answer
5k views

Thread-Safe Task Queue Implementation

Purpose: This class exists to ensure actions created from other threads are executed in a synchronous manner. Additionally, it provides functionality to add actions that run after a delay. Code: (...
jhmckimm's user avatar
  • 151
9 votes
2 answers
1k views

C++11 Blocking connection pool with auto release

Relatively new to C++. Please help me understand the potential issues with the following blocking object pool. ...
271828183's user avatar
  • 189
4 votes
1 answer
144 views

Link checker using Go channels

I've started to learn Golang and channels in it. I decided to write simple application - recursive link checker. Given some URL it tries to retrieve pages, parses them and goes deeper. Here's a code ...
Eugene Lisitsky's user avatar
6 votes
3 answers
2k views

Concurrently reading a Map while a single background thread regularly modifies it

I have a class in which I am populating a map liveSocketsByDatacenter from a single background thread every 30 seconds inside ...
user5447339's user avatar
2 votes
0 answers
635 views

Producer / consumer pattern with limits on .NET

For a project that I'm developing, I need to implement the producer/consumer pattern, but the quantity of consumers cannot be higher than some number (say 40). I created a concept project on GitHub ...
Vladimir Venegas's user avatar
1 vote
1 answer
94 views

canonical pattern for transactional library state manipulation

In golang I am finding that there is a definite pressure in the language itself and built-in libraries to do things in a canonical way. Please can someone critically look at these two ways I am ...
RidiculousRichard's user avatar
4 votes
0 answers
68 views

Fast lock implementation using pipes only

For fun I wanted to create a lock implementation that was about as fast as one using futexes but that used used pipes instead and that queues waiters in user space instead of in-kernel. For the queue ...
Molly Stewart-Gallus's user avatar
1 vote
2 answers
96 views

Simplified LogService (from concurrency in practice) with shutdown feature

Brian Goetz provided following code of LogService with shutdown feature: ...
gstackoverflow's user avatar
2 votes
1 answer
102 views

Repeat operation if signal is received

I have a data synchronisation operation that is observing a database. This is a fairly key piece of code for the system, so I want to make sure I handle the concurrency correctly. The problem The ...
Gusdor's user avatar
  • 161
4 votes
1 answer
458 views

Concurrency and locking in a chat server

I've never done concurrent programming before, but I've written one using go channels and RWMutex, but I'm not sure if my approach is idiomatic. I feel like it could all use channels (Maybe). The ...
wingerse's user avatar
  • 214
3 votes
1 answer
2k views

JUnit assertion for concurrency test

I'm learning Java concurrency by a TDD approach. Therefore I wrote a basic test case in JUnit to test the behaviour / expected results of 2 threads. I'm looking for feedback for this code. In ...
Mincong Huang's user avatar
0 votes
1 answer
1k views

Turn a non-blocking concurrent queue into a blocking concurrent queue

Microsoft Visual Studio offers a non-blocking concurrent queue class, concurrency::concurrent_queue, based on Intel's TBB. I am using this as a base for a blocking ...
Jamerson's user avatar
  • 303
0 votes
2 answers
4k views

Concurrent Stack with blocking and non-blocking methods

I wrote it this just for learning. Is there holes at this code? ...
gstackoverflow's user avatar
1 vote
1 answer
601 views

Concurrent blocking stack

I just want to train before interview. I googled concurrency interview questions and one of the question was write concurrent ready stack. ...
gstackoverflow's user avatar
2 votes
2 answers
4k views

Running multiple producer and single consumer in a multithread environment

I have a below class in which add method will be called by multiple threads to populate messageByChannelReference concurrent ...
user1950349's user avatar
3 votes
1 answer
371 views

Parallel brute-force solution for Project Euler 4 (Largest palindrome product)

The pe4Concurrent.go file given below is my first attempt at writing a concurrent programme, pe4.go is a non-concurrent implementation of the same algorithm for comparison purposes. The algorithm ...
R. Duke's user avatar
  • 133
3 votes
0 answers
72 views

Creating an observable stream of clicks and converting it to an iterator

Problem 1 StratifiedJS allows people to cleanly create observable streams using the Stream class from sjs:sequence: ...
zamfofex's user avatar
  • 131
0 votes
1 answer
282 views

Caching wrapper for digest computation

I need to review this code: ...
gstackoverflow's user avatar
2 votes
1 answer
381 views

Receiving messages from TCP socket and processing them

I would like someone to look at my class for reading messages from a network socket. In short, the whole app should behave like a regular ping command with some additional functionalities. The point ...
pord911's user avatar
  • 43

1
3 4
5
6 7
10