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.
2
votes
0answers
21 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:
class ...
7
votes
1answer
140 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 automatically on timeout. So, I decide ...
4
votes
2answers
84 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 make my own and would like some ...
6
votes
1answer
68 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
49 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:
let fileContents =
[ "filename1"; "filename2"; "etc" ]
|> Seq.map(fun file -> async {
use fs = new ...
3
votes
0answers
19 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 method is:
SELECT *
FROM article
WHERE ...
5
votes
3answers
103 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?
@ThreadSafe
public class RetirementAccount {
public static final int TYPE1 ...
2
votes
1answer
152 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
87 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
233 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
62 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
155 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.
public class HealthChecker {
private static ...
3
votes
1answer
86 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
254 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 build something similar using ...
2
votes
2answers
104 views
Testing an Executor
I have written the following Executor:
/**
* <p>This executor guarantees that there is never more than one element waiting to be executed. If an element is
* submitted for execution and ...
4
votes
1answer
296 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 clients, I implement producer–consumer pattern with a queue into a Thread ...
8
votes
2answers
212 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 ...
1
vote
2answers
292 views
Looking to improve 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
258 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 something with it. What do you think ...
1
vote
2answers
3k views
Reading output from multiple threads and writing to a file
There are 10 threads and I have 15 tasks. Now I have submitted all these tasks to these threads. I need to write all these threads output to a file which I was not successful.
I am getting output by ...
1
vote
1answer
101 views
Review of concurrent php logic for a web spider class
I wrote a web spider that I would like to download and parse pages concurrently. Here is what I am trying to achieve:
instantiate a new instance of the class with the $startURL as the constructor
...
3
votes
1answer
75 views
Sleepsort in Go
I implemented sleepsort in Go. I am new to channels, and I'd like to get some advice on them, especially on how to close channels after N messages have been sent on them. Currently I use a counter and ...
1
vote
2answers
796 views
ReentrantReadWriteLock lock upgrade method
I have a question about lock upgrading.Specifically what bothers me is between readlock.unlock() and following writelock.lock()...
I am providing a nearly complete implementation for a sample cache.I ...