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
54 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 ...
9
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
684 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
104 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
41 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
59 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
73 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
84 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
71 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
55 views

Best way of 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
55 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
66 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
50 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 ...
0
votes
0answers
62 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. ...
3
votes
0answers
116 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
48 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
73 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
69 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 ...
0
votes
2answers
128 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
46 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 ...
12
votes
2answers
214 views

Can I make the thread safe case faster?

The code below is part of one of my projects called largetext, which actually stemmed from a question on StackOverflow. The goal is to provide access to a very large text file as a ...
12
votes
2answers
104 views

java.util.concurrent bounded resuable resource implementation

I'm trying to code following requirements with lockfree in most-used-code-path that is to get a resource from pool. Same resource should be used n (maxUsageCount) ...
9
votes
2answers
140 views

Concurrent task processing queue

I can have a maximum of three concurrent threads processing tasks. Each of these threads can process 1 to 100 tasks simultaneously (by connecting to an external system). The time taken to process 100 ...
7
votes
2answers
181 views

Python Port Scanner 2.1

I made lots of changes to the script presented in my previous question. I was tempted to edit that one with the new code, but it would invalidate @200_success's helpful answer. It was also ...
3
votes
1answer
101 views

Python Port Scanner 2.0

A few months ago I put up a port scanner for review. Now, I've updated it with some new Python knowledge and integraing the feedback I got. Some things I specifically think might be wrong with it or ...
1
vote
0answers
51 views

Reliability of flock mutex (LOCK_EX|LOCK_NB)

I would like to test reliability of system flock in a multi-threaded and concurrent environment as some suggest that they are not reliable (in comments). Thus I ...
10
votes
2answers
73 views

Poke-a-Dot (Provider)

I need to create variable-length strings of dots/periods/full-stops to add to some text content, in a way that is similar to a formatted table-of-contents: ...
2
votes
1answer
70 views

Decoding big text input: potential concurrency bugs?

The code here will be directly pasted from this project. Quick summary: it is related to a Stack Overflow question. So, basically, all the code below aims to implement ...
11
votes
2answers
183 views

Is this use of a resource based on session ids thread safe?

Let me first describe the expected behavior of the code below: There will be one static SessionManager accessed by many threads. Multiple calls to ...
4
votes
2answers
500 views

Wait until all files are loaded asynchronously, then run code

I'm an experienced programmer but not too great at JavaScript so I'm looking to see if I'm doing this 'right'. I want to have several files loaded in (Ajax or really AJAJ) and, once loaded, run some ...
1
vote
2answers
82 views

Am I risking a deadlock in this manner of re-queueing up events?

I have a DelayQueue in Java, which multiple threads will read from. They will then perform a task, and call a requeue method which performs some mathematical logic ...
3
votes
1answer
117 views

TaskScheduler that uses a dedicated thread

I'm trying to implement a TaskScheduler that runs all tasks in the order they are submitted, on a single dedicated thread. Here's my implementation, using a BlockingCollection: ...
8
votes
1answer
190 views

Cache<Long, BlockingDeque<Peer>> combined with Striped<ReadWriteLock>: is it thread-safe

I've implemented PeersContainer class with all operations that I need. I need something like multimap in concurrent environment, moreover I need remove entities ...
5
votes
2answers
284 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 ...
6
votes
1answer
157 views

A non-blocking lock decorator in Python

I needed to impose on a Python method the following locking semantics: the method can only be run by one thread at a time. If thread B tries to run the method while it is already being run by thread ...
2
votes
1answer
117 views

Is this a good use of Async in F#?

I've hacked together some code to read the content from a sequence of files: ...
5
votes
1answer
38 views

Updating number of article views - potential concurrent access issue?

I have articles on my website (built in PHP) and when an article is viewed the number of views is recorded back in the database. The SQL code snippet of my load ...
5
votes
3answers
124 views

Feedback on thread safety of the classes

I have following classes. Are they properly guarded for thread safety? Do you see any issues with any of the classes? ...
1
vote
1answer
181 views

Automate a dependency graph with parallel programming [closed]

I found a C/Linux exercise in a book, and I propose a code as a solution, please feel free to correct it. Here is the exercise : Taking into consideration the following dependency graph, which ...
1
vote
2answers
117 views

Is that correct example of unsafe publication in java? [closed]

There are many examples of unsafe publication on the web. But I cannot find a complete program for reproducing it. I wrote an example but I do not sure whether it correct or not. And in case of ...
6
votes
3answers
681 views

How can I improve the performance of this concurrent http request loop?

I'm using the rolling curl library to fire http requests for content-length headers of images (we need to know their size to weed out placeholders and low res images). The image urls are stored in a ...
4
votes
2answers
120 views

Double checked locking 101

I've found a peace of code I've wrote not long ago. It is used to fetch some dictinary from DB table only once and then return it to requestors. Seems like I tryed to implement double-checked locking ...
10
votes
4answers
750 views

Concurrent multi-server pinging in Java

I have an application that essentially "pings" all of the servers on my network. I have about 100 servers, and this ping will happen every 10 seconds. ...
3
votes
1answer
129 views

Web Crawler (A Tour of Go #71)

So I was trying to do this exercise from Tour of Go. I managed to get it working. I am not at all sure that it is correctly concurrent or idiomatic (I started learning Go, like, 4 hours ago). I would ...
1
vote
2answers
754 views

Producer-Consumer using low level synchronization

I saw a tutorial from a site where it showed the use of ArrayBlockingQueue as a thread-safe concurrent data-structure . Just for learning purposes , i tried to ...
2
votes
2answers
142 views

Testing an Executor

I have written the following Executor: ...
4
votes
1answer
773 views

Unit test an ExecutorService in a deamon

To execute tasks sequentially with a timeout I use ExecutorService.submit() and Future.get(). As I don't want to block calling ...
8
votes
2answers
424 views

How can this simple coroutine implementation be improved?

This is a quick and dirty implementation of coroutines that implements yield by saving and restoring the stack to and from the heap. Here's an earlier version, which does the most naive possible ...
2
votes
2answers
439 views

Mutex implementation

Overarching Problem I am creating a threadsafe queue that will act as a shared buffer between two threads for a game I am developing. I need it to be threadsafe so that one thread can throw messages ...
4
votes
1answer
294 views

Self-taught Pythonista: Any criticism welcome for this concurrent word count script!

I've been teaching myself Python - my first programming language - for about two years now. I recently discovered the concurrent.futures module and wanted to do ...