Arises when multiple threads can simultaneously access the same resource. Use this tag for code reviews of multithreaded code where concurrency is a potential issue.

learn more… | top users | synonyms

1
vote
1answer
25 views

Parallel for loop in Java 8 - follow-up

The previous and initial iteration at Parallel for loop in Java 8. Changes are as follows: ParallelLoopBody removed; ...
3
votes
2answers
48 views

Parallel for loop in Java 8

This is my first attempt to provide some syntactic sugar for doing mutually independent loop iterations in parallel. Thanks to Java 8 lambdas, I can write the parallel loops in pretty elegant fashion ...
4
votes
0answers
52 views

Custom TCP java proxy socket load balancer

I´m working on implementing a custom TCP proxy server which acts like a load balancer. The proxy server will accept client requests and then forward them to available hosts. I am concerned about the ...
2
votes
0answers
25 views

NoSQL-based sequence generator

For my web application I have to generate a sequence of following format: <year><sometext><month><sequence> For example: ...
2
votes
1answer
42 views

Does this usage of AtomicLong look thread-safe?

I wanted to ensure that lastActivityTime is always the "latest" value based on current time, but I wonder if my "update" method is thread-safe? If it's not, what's a better solution besides just ...
0
votes
2answers
36 views

Java background server class that might be called from ui thread

I have a server communicating over network interface. This server should run on a background thread, so that it does not block the ui thread. The ui thread starts and stops the server. Even starting ...
5
votes
2answers
111 views

Time Sensitive ConcurrentDictionary

In our application, we have many function calls that we want to cache the results of. However, the result of these functions depends on database calls, so we want this cache to refresh every so often ...
8
votes
0answers
50 views

Go Go Gadget Web Crawler

In A Tour of Go, you are given the following problem: In this exercise you'll use Go's concurrency features to parallelize a web crawler. Modify the ...
2
votes
0answers
42 views

Is this web service synchronized correctly?

I'm new to both concurrency programming and Go. I've written a small server side script that gets the title and ratings of a book for a given ISBN. I've to optimise performance by using a cache and ...
3
votes
2answers
57 views

Correct way of implementing thread safe factory with caching?

I have a ConnectorFactory that creates Connector objects based on parameters like URLs, username and passwords. The ...
5
votes
1answer
62 views

General Batched Job Runner

This question is inspired by: Generic Task Scheduler where the problem is to run tasks on a scheduled basis, in parallel, and have individual timeouts for each job. For example, consider this ...
2
votes
1answer
52 views

Precognitive waiting - waiting for something to finish, before it starts

I have implemented a class that has a method to wait until "something else" has happened. When this has happened, the current thread stops waiting and returns from the method. This is my current code: ...
7
votes
1answer
111 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 ...
5
votes
1answer
41 views

Concurrently Iterable Poor Array List

As I wrote on SO, I need an ArrayList-like structure allowing just the following operations get(int index) add(E element) ...
3
votes
1answer
63 views

Non-concurrent write creates bottleneck

I have some efficient methods that recursively creates a tree structure (NSTreeNode) of by looping recursively over a directory structure. The result is displayed ...
6
votes
2answers
283 views

Solving a race condition

In my application, I have a message dispatcher. Each message gets relayed to a dispatcher thread. In some scenarios, I can get two responses from the third party in the same millisecond: An "I ...
10
votes
2answers
211 views

Threadsafe HashMap with snapshot support

The problem ConcurrentHashMap provides very weak consistency guarantees w.r.t iteration: guaranteed to traverse elements as they existed upon construction exactly once, and may (but are not ...
1
vote
1answer
46 views

Multithreading synchronization between reading and writing in a channel

I was hoping to get some feedback on what the recommended design pattern are for this subject. ...
8
votes
2answers
171 views

Concurrent Task Waiter 2

This is an iteration of my previous question: Concurrent Task Waiter Summary from before: I have some code designed to simplify managing multiple asynchronous operations. The code creates ...
1
vote
0answers
30 views

Daisychain channels

I watch the presentation about concurrent programming presented by Rob Pike and I saw the daisychain example. I tried to rewrite this code to make it more readable. Everything went well, but I am ...
1
vote
1answer
55 views

Concurrent Task Waiter

I have some code designed to simplify managing multiple asynchronous operations. The code creates callback actions that, when executed by the asynchronous operation, track which asynchronous methods ...
1
vote
1answer
60 views

Optimizing code using semaphore to control Netty channel pool - Part 2

Please have a look at my original question: Optimizing code using semaphore to control Netty channel pool I have made some changes as pointed out by @rolfl The new code is as follows. Is this ...
3
votes
1answer
101 views

Optimizing code using semaphore to control Netty channel pool

I am using Netty to exchange messages between a client and server. For this, I am maintaining a channel pool on client side. Please help me in optimizing this code. ...
8
votes
1answer
59 views

Shady Characters

As part of my familiarization with the features of Java 8, and inspired by this question, I thought I would take the 'Shady Character' problem to 'the next level'. Find sum of number of times that ...
6
votes
2answers
424 views

Parallel “wget” in Java

Purpose: write Java program that downloads a list of URLs specified on commandline in parallel (simultaneously), reporting download completion every second. My solution follows below, please point ...
0
votes
0answers
107 views

Push-pull pattern with nodejs and zmq

I created the code below to illustrate push-pull pattern with zmq and to benchmark some concurrent job. ...
27
votes
3answers
1k views

Voxel World Optimization

This is not related to a Minecraft clone. I am currently writing a turn-based strategy game like Final Fantasy Tactics. The game is played on floating voxel-style islands, which are generated from ...
5
votes
1answer
177 views

Concurrent Linked Hash Set

Basically I want to create a concurrent LinkedHashSet which returns proper size too. I am mainly concerned about adding and removing iterations. Suggestions ...
10
votes
2answers
157 views

RAII Pattern for Downgradable ReadWriteLock

The example for downgrading ReentrantReadWriteLock in the Java documentation seems really unsafe when handling exceptions. I tried to write a simple class to simplify it. Do you see any cases where it ...
1
vote
2answers
109 views

Large arrays make runtime very slow

So I have the following code that takes the input of two arrays, and apply some queries to match elements from DBpediaClassesArray with elements from ...
10
votes
4answers
1k views

Send email just once per day

I want to send an email just once per day. There is one button and any user can click that button. The email must not be sent twice. When the first user clicks the button, the email is sent. If ...
15
votes
2answers
785 views

Using Java 8 parallel streams

I'm trying to get more familiar with the new Java 8 features, so I am rewriting one of my earlier projects. It includes a class that keeps track of the best entry seen so far: ...
2
votes
1answer
1k views

Readers-writers problem using wait notify

Description of the Readers–writers problem. It looks like it works, but I have some doubts: ...
2
votes
1answer
50 views

Parallel Reduction method with C++AMP

I am writing a C++AMP library, and as one of my utility methods I am implementing a parallel reduction algorithm based on the cascade method documented on this blog post with slight improvements by ...
1
vote
2answers
80 views

SynchronizedArrayList implemented using reader writer synchronization

I am trying to understand the workings of reader writer locks. For the sake of learning, I implemented reader writer synchronization by my own. I implemented ...
5
votes
2answers
329 views

Queue that connects multiple producers and multiple consumers

The scenario is about processing 'Message' objects. Producer creates them and Consumer does the consumption. ...
6
votes
2answers
97 views

Is this a good way of managing parallel go routines when I care about ordering of results?

I have a process with a number of stages that need to be completed in sequence. Each stage is largely parallelisable, involving looping over a large data structure and processing each item ...
1
vote
0answers
191 views

HttpRuntime.Cache cache manager class

I am making code review of legacy class, which manages caching logic. Caching logic uses ASP.NET webforms HttpRuntime.Cache. I know class, that is posted below, is ...
2
votes
1answer
93 views

Assigning an array of different (but convertible) type to concurrency::array in C++AMP

I am creating a vector class which can be manipulated on the GPU and I am using C++AMP for the GPU accelerated code. I am wondering the most efficient way of assigning elements of a different type ...
1
vote
1answer
59 views

Will this act like a ThreadPool? [closed]

I know that until the n threads will not complete their jobs, the new jobs will not be assigned, but will this code be thread-safe and execute ...
1
vote
1answer
116 views

Split download file buffer by any number of threads

This is my first attempt at splitting the download buffer into several threads by the number provided. I want to improve on performance and better implementation approach. ...
2
votes
1answer
69 views

PPL and AMP performing worse than sequential transform

I wrote the following short test code to test the performance of C++AMP and the PPL libraries against the sequential STL implementation of std::transform. To my ...
1
vote
0answers
132 views

WebApi synchronize database (EF 6) access

I'm working on an ASP.Net MVC 5 /WebApi 2 project. I'm using EF 6 code first for my database access. I've a WebApi action method in which I've to update some data in my database based on the request. ...
5
votes
0answers
157 views

Concurrent queue

I recently wrote a concurrent, mutex-less (but not lockfree) queue and wanted to know if it is actually correct, and if there are any particular improvements I could make: ...
4
votes
1answer
60 views

Try a speculative, concurrent, lock free, atomic update until abort condition matches

Please let me know if you see any performance improvements, bugs, or anything you'd change and why. ...
3
votes
0answers
87 views

Concurrent download in Go

I wrote a program for downloading files in concurrent / parallel (GOMAXPROCS > 1) manner. This is my 2nd (non-toy) program written in Go. Please point out areas for improvement: ...
2
votes
1answer
95 views

Testing Promises vs Lock performance

I'm not sure if my lock usage is correct and safe. I wanted to know what will be best approach to deal with situation when one thread have to wait for being initialized by another so I written this ...
4
votes
1answer
141 views

Is there a better way to copy into two different folders on a machine simultaneously?

I am trying to copy files from machineB and machineC into machineA as I am running my below ...
0
votes
2answers
306 views

Continually process results of multi-thread worker [closed]

Let's say we've got some SQL queries and want to display the results. Processing takes some time, so I do it multi-threaded. The following works quite well for me. I reduced the code to the important ...
3
votes
1answer
75 views

Concurrent non-blocking refresh

In my application there is a "config" object that is accessbile by multiple threads concurrently. It is a single object (singleton) injected by the DI in the "dependents". Until now, this (the ...