What's the deal with Deno? We talk with a major contributor to find out. Listen now.

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
3
votes
1answer
1k views

Are there pitfalls to this solution to read messages from a queue in parallel?

I've posted a question on stackoverflow: How can I consequently read messages from a queue in parallel? I would like my own answer to be reviewed. Situation We have one message queue. We would like to ...
7
votes
1answer
54 views

Refactoring a phantom server called Swayzee

I have made a tool that is pretty useful for me. I have made it open source on github. It is a server that listens for requests and returns an HTML static version of a single page app. It works with a ...
3
votes
0answers
127 views

Implementing a long-running entity lock

Requirement I have an entity named ImportData which can be processed once in order to extract data from a file fed to the application. I need to make sure that, in ...
2
votes
1answer
484 views

Unfair semaphore in Java

I'm tutor for a university operating systems course, and part of my work is creating exercises for them. Those exercises are mostly about concurrency and synchronization issues. For the next exercise ...
4
votes
2answers
2k views

Parallel foreach with configurable level of concurrency

The purpose of this code is to let me loop over 100 items (up to MAX_CONCURRENT at a time), performing some action on them, and then return only once all items have ...
10
votes
1answer
366 views

ConcurrentDecayingHashMap<K,V>, a concurrent decaying HashMap

I wrote a wrapper for Java's ConcurrentHashMap that enables you to add a decay time to inserted values, meaning they will be automatically removed after the given ...
3
votes
2answers
78 views

Visualize the runtimes of list algorithms

I wrote a small script to visualize the runtimes of list algorithms. The script works by creating a list of lists with sampled lengths from 1 to max_size. Next, I ...
5
votes
2answers
129 views

Lock implementation using atomics

I was recently given an interview and was asked to write my own lock implementation using atomics, but not necessary reentrant. I didn't answer the question, but at home, I wrote this code. Please ...
10
votes
1answer
1k views

“Barbershop”-esque Semaphore Implementation

Recently, I submitted a project that simulates a barbershop-style problem; the task was to create a Hotel that contained guests, front-desk employees, and bellhops. ...
7
votes
1answer
528 views

Fast non-fair semaphore

This is a simple non-fair semaphore implementation using Java atomic objects. It currently performs a little over twice as fast as java.util.concurrent.Semaphore on ...
1
vote
0answers
87 views

Self cancelling period tasks

I've got a piece of code that will run a period task to do a small bit of processing. The task depends on an externally managed connection resource, and if the resource goes away then the task should ...
0
votes
3answers
1k views

Implementing multiple Producer Consumer using custom Blocking queue [closed]

I am trying to implement multiple producer multiple consumer problem using a custom blocking queue. The requirement is that: If the queue is not full, all the producers should be able to produce ...
9
votes
1answer
11k views

Printing even and odd using two concurrent threads

Please review the code below where thread Odd prints all odd numbers from 1 to 9 and thread Even prints all even numbers from 2 to 8. I tested it and it works but can we improve it from design or ...
6
votes
2answers
3k views

Canonical Implementation for a Concurrent Subclass of NSOperation in Swift 2

I would like to develop a kind of template or canonical implementation for a concurrent subclass of NSOperation in Swift. See here for my previous request which is implemented in Objective-C. In that ...
3
votes
3answers
419 views

SPSC Wait Free Ring Buffer for incoming messages

This is for a single producer and single consumer wait free ring buffer. The writes need to be wait free for sure. It pre-allocates messages slots and uses a claim strategy to capture a buffer for ...
4
votes
1answer
1k views

OutputStream class for use with subprocess.Popen

I've recently been writing an application which does a lot of work with the output of commands. To call the commands I've been using the subprocess module, and originally, was using ...
2
votes
1answer
207 views

Java “pulse” between threads

I have two threads. One runs a simulation and one runs a UI. In the UI, it is possible to trigger a "tick" of the simulation. There are a few constraints: Ticks run on the simulation thread Each ...
5
votes
1answer
102 views

Baby Step Giant Step Discrete Log Solver

I've made a concurrent implementation of the Big Step Giant Step discrete log solver in Go. I'm pretty new to this branch of math, but it seems slow. Any way to speed it up or is this the limit of ...
3
votes
1answer
428 views

Parallel scheduler for running actions at designated times

I've been trying to learn Haskell on and off for a couple years. I had a project for building a parallel web scraper, and I figured I'd try to use Haskell for it. Here's the part used to schedule ...
5
votes
1answer
54 views

Class managing queuing updates from another thread, Version 2

This is an updated version of: Class to manage updates coming in from another thread Managing updates from other threads into Swing is a hard problem. In MVC design, if you don't want to have the ...
1
vote
0answers
121 views

Batching using semaphores

I need to batch messages when pushing them, where multiple threads do the publishing. What could be a better way of doing this? ...
5
votes
2answers
71 views

Class to manage updates coming in from another thread

Managing updates from other threads into Swing is a hard problem. In MVC design, if you don't want to have the Presenter be responsible for Thread safety, you can end up with deadlock issues, and also ...
5
votes
1answer
354 views

Multi-threaded bitcoin vanity address generator written in Java

The application leverages the bitcoinj library to generate a vanity bitcoin address. A vanity address is simply a bitcoin address that contains a personalized string. I would like some critical ...
1
vote
1answer
775 views

ArrayBlockingQueue - blocking drainTo() method

This is a follow-up question to this question. Is this a reasonable implementation for a blocking version of method ArrayBlockingQueue.drainTo(Collection)? ...
6
votes
1answer
99 views

Creating an in-memory ViewCounter that commits to database every 10 minutes

This singleton is responsible for counting every pageview (called Routes in our case) we get by id, until the timer runs out and commits the results to the database in one query. Then the counter gets ...
2
votes
1answer
66 views

ReadWriteMap implementation

I had a task to realize ReadWriteMap ...
4
votes
2answers
730 views

Debounce in Scala

This is my attempt at implementing debounce in Scala without any 3rd party library. How can I improve the code/make it more idiomatic (and any bugs I might have missed)? ...
-1
votes
2answers
5k views

Simple Implementation of a ReentrantLock

An implementation of a ReentrantLock: ...
-2
votes
2answers
489 views

Simple Implementation of a BlockingQueue

An implementation of BlockingQueue ...
7
votes
2answers
4k views

Queue for distributing tasks between threads

I implemented the following class to dispatch std::function<void(void)> objects to a thread pool. Multiple threads will block on the pop call until a task is ...
12
votes
1answer
453 views

Concurrency interview

A little while back I had an interview where they posed a problem, in summary: Watch a certain directory, and process incoming JSON files These JSON files have various "Type" fields Every second ...
5
votes
2answers
1k views

Serialize/deserialize objects to and from database concurrently

I have a class which runs as spring bean in the container and its purpose is data persistence. In the overriden method ...
5
votes
1answer
2k views

ConcurrentHashMap Implementation

I have written a simplified version of my own MyConcurrentHashMap. I tried to make use of a Lock[] array for ...
1
vote
1answer
1k views

Implementation of self-updating, asynchronous cache solution of individual (non-bulk) objects

Here I am again; referring to my previous code review request about a self-updating, asynchronous (?) cache. The previous class takes care of caching operations like "get all users registered in our ...
0
votes
2answers
761 views

Implementation of asynchronous (?), self-refreshing cache of object collection bulk

I'm trying to create a caching solution used in various parts of a clients' application. The resulting code will be open source. For example, it will be used for caching API queries like "get all ...
2
votes
1answer
118 views

Using goroutines to bruteforce a secret code

For a puzzle I had to brute force a password. I've never used goroutines before, and I don't have much experience in concurrency. This is the cksum function, which takes an array of the ASCII code ...
5
votes
1answer
1k views

Hybrid Lock Implementation

I have an algorithm that is painfully slow if I use 'pure' mutexes. That's because most of the critical sections are short and far shorter than the work to sleep a thread. However, it is also slower ...
4
votes
1answer
456 views

Multithreaded scoreboard for different levels

For an assignment I had to create a highly multi-threaded scoreboard for a multi level game. So every time a user adds a score if the level doesn't exist, it gets created ad-hoc. Important point: a ...
3
votes
1answer
287 views

Non-blocking solution to the dining philosophers

This is one of tasks, which I had to do for the recruitment process to be started in some company. Unfortunately they didn't like it so I've decided to share it here for discussion. Philo5.h ...
-1
votes
1answer
93 views

Removing an element and the element following from an ArrayList [closed]

I have an ArrayList of Strings. I want to delete all elements with a particular value and the element immediately after that one. I have an ArrayList with the elements "Ape", "Bear", "Cat", "Dog", "...
5
votes
1answer
2k views

A Stream wrapper that executes all writes asynchronously

I wanted to make a Stream that can wrap another stream and buffer all writes, to increase performance; comparable to the ...
2
votes
2answers
43 views

Storing recent search phrases

I have a search on a very simple spring-powered website and I want to display 10 recent inputs: ...
3
votes
1answer
420 views

Implementation of FastICA in multithreading approach

I am to implement a parallel version of FastICA, so I implemented the serial version of FastICA. Now this is the architectural diagram of how it is going to parallelize. I just coded a basic ...
2
votes
1answer
2k views

Message queue with multiple producer, single consumer and no duplicates

I had to make a message queue in an android app which my thread takes messages from and processes them. There can be multiple producers and duplicate messages should be avoided. Rate of insertion is ...
9
votes
1answer
5k views

Continuation Implementation in C++11

While playing with the concurrency features in C++11 I noticed that there wasn't any support for continuations. I wanted to develop something similar to Tasks in The Parallel Patterns Library (PPL), ...
2
votes
0answers
97 views

Parallelized image transformations using GraphicsMagick

This is part of a script that I use for porting a TWRP theme from one resolution to another, respectively portrait to portrait and landscape to landscape. In this function entirely, it focuses on the ...
2
votes
0answers
95 views

Porting Java semaphore to MacOSX

I wanted to write some more JNI code and decided to (re)implement a semaphore for MacOSX. In order to assert somehow correctness of my implementation I hereby supply a (multi)consumer/(multi)producer ...
6
votes
1answer
1k views

C++ concurrency library

I started a C++11 library of concurrency primitives in order to study and compare their performance; provide high-quality implementation of those to use in my projects. Its main target platform is ...
-1
votes
2answers
79 views

Replacing Synchronization with Atomics

I have tried to make modification in below specified code by removing synchronized and replacing Integer with AtomicInteger . ...
4
votes
2answers
4k views

ArrayBlockingQueue: concurrent put and take

I have implemented an ArrayBlockingQueue (put and take) on the lines of LinkedBlockingQueue i.e using two locks so that my take ...

1
4 5
6
7 8