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 ...
2
votes
1answer
12 views
A multi-threaded Producer Consumer with C++11
I am trying to learn concurrent programming in C++11. I tried to write code for a classic producer consumer concurrency problem. Would you please review and make any comments about it?
...
2
votes
1answer
45 views
Readers-Writers problem in C
I would love some suggestions on this code of mine, pointers on overall design, code quality, optimization in terms of memory and speed.
...
3
votes
1answer
52 views
Reducing lock contention for a caching utility, or make it totally lockless but threadsafe
My Java program is a module called configProxy which fetches configuration entries from a remote node (say from a Redis instance). When the caller calls the ...
6
votes
0answers
78 views
Cache for JSON API
I am working on a small project which utilizes a 3rd party API. Many of the queries from the API can take 5-10 seconds so to keep the front end moving a bit faster I decided to cache the responses ...
3
votes
1answer
53 views
Concurrent LRU cache using sychronizedMap() or ReadWriteLock
Trying to implement a simple, thread-safe LRU cache that's meant for "read mostly" use.
Collections.sychronizedMap()
Clean, simple, not much else to say.
...
7
votes
1answer
96 views
Code snippet for a method dealing with IDs from multiple threads
I have multiple threads calling a method, passing in an ID and value.
I have two constraints I need to place on this method:
Only one of the same ID can be processed at a time. Additional threads ...
1
vote
0answers
28 views
Technique to destroy classes and mutexes used by several concurrent threads [closed]
I would like to get some advice and reviews regarding to the following code:
Code 1:
...
3
votes
1answer
59 views
Execute startup method asynchronously
The goal is to call startManager on application start so that the manager is initialized in background without blocking application main thread.
Is it a safe ...
3
votes
1answer
37 views
Walking and comparing contents of binary trees
I've written a solution for http://tour.golang.org/concurrency/8, which asks for a Walk() function to traverse a randomly generated binary tree, and a ...
2
votes
0answers
155 views
Golang concurrent HTTP request
I wanted to test the performance of concurrent http request in Go against node.js:
...
3
votes
0answers
86 views
Blocking builder with singleton
I am trying to implement a singleton builder that would be shared across
multiple builder threads for Coordinate objects.
Here is the simplified target class ...
7
votes
1answer
132 views
Sorting Algorithm Visualizer
Over the course of the past month I've worked on a little visualizer to show how different algorithms are sorted. I'm pretty happy with how it turned out but would be interested in any feedback ...
3
votes
3answers
100 views
Producer-consumer code
The idea I have in my head is this:
I am not sure if I need the index variable in consumer and producer.
Moreover, I want to know if it is OK like this (it ...
0
votes
0answers
33 views
Parallel for loop in Java - follow-up 2
The previous iteration at Parallel for loop in Java 8 - follow-up.
The changes are as follows:
MyTask is removed.
Synchronization removed. Now the user is ...
1
vote
1answer
96 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
90 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 ...
7
votes
1answer
251 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
51 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
61 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
51 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
163 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 ...
12
votes
1answer
163 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
47 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
125 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 ...
6
votes
1answer
83 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
66 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
392 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
56 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
73 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
3answers
435 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
284 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
57 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
187 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
33 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
69 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
150 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
153 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.
...
9
votes
1answer
62 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
715 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 ...
28
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
2answers
312 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
178 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
133 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
976 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
2k 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
67 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
93 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 ...
6
votes
2answers
441 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
103 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 ...