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
1answer
349 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
179 views

Copying 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 shell ...
0
votes
2answers
4k 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
434 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 "config"...
13
votes
2answers
492 views

Thread-safe large text buffer

This is part of one of my projects called largetext, which actually stemmed from a question on Stack Overflow. The goal is to provide access to a very large text file as a ...
12
votes
2answers
175 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) ...
11
votes
2answers
10k 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 ...
12
votes
2answers
2k 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 ...
5
votes
1answer
932 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
312 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
116 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
116 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
2k views

Thread-safe session manager

Expected behavior of the code below: There will be one static SessionManager accessed by many threads. Multiple calls to ...
7
votes
2answers
36k 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
107 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 (...
9
votes
2answers
3k 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 ...
8
votes
1answer
448 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 ...
6
votes
2answers
3k 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 ...
8
votes
1answer
2k 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 A,...
2
votes
1answer
518 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
53 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 ...
6
votes
3answers
183 views

Thread-safe retirement account class

Are these classes properly guarded for thread safety? Do you see any issues with any of the classes? ...
7
votes
3answers
3k views

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 ...
6
votes
2answers
832 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 ...
6
votes
1answer
2k views

Concurrently enumerating an array using blocks in a thread-safe way

I have an array that I want to enumerate using blocks concurrently. However, I'm having trouble making this thread safe. I am new to using blocks and locks, so I am hoping someone may be able to push ...
10
votes
4answers
8k 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. ...
4
votes
1answer
906 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
4k 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 ...
4
votes
2answers
12k views

Testing an Executor

I have written the following Executor: ...
4
votes
1answer
5k 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 ...
11
votes
2answers
3k 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 thing,...
6
votes
3answers
15k 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
406 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 ...
3
votes
2answers
29k 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
158 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 ...
8
votes
3answers
27k views

Dining philosophers problem with mutexes

I know this dining philosophers problem has been researched a lot and there are resources everywhere. But I wrote simple code to solve this problem with C and then turned to the Internet to see if it'...
4
votes
1answer
111 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 ...
2
votes
1answer
1k views

Performing tasks concurrently

I made a class to perform tasks concurrently and have implemented it. From appearances and testing, everything seems to work. How can I improve this? I understand this is somewhat a broad question, so ...
0
votes
1answer
512 views

Simplifying and optimize a concurrent access

I have code that is accessed by multiple threads. If by any chance it has a problem, all accessing threads will wait for recovery. By default, the first thread that fails, will have to recover and ...
2
votes
2answers
4k 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 ...
5
votes
2answers
4k views

Reader-writer collection

This is based on Alexey Drobyshevsky's excellent article, "Problems with Iteration". With Alexey's suggestion, I implemented his solution using a ...

1
4 5 6 7
8