Tagged Questions
1
vote
0answers
48 views
Synchronous cinema hall, with StampedLock
I'm beginner in Java concurrency mechanism. I wrote some application to train a synchronization between many threads. I noticed that I wrote a lot of if statements, and it looks really ugly. Maby is ...
1
vote
0answers
41 views
MVC web app writing to file in a threadsafe way
This is as much a code design question as a code review. I am adding some temporary code to my website to record search terms used. For now I'm also storing a few other fields. This is an ...
3
votes
0answers
36 views
Implementing non-blocking Executor.map
I wanted to extend concurrent.futures.Executor to make the map method non-blocking. It seems to work fine, but I would be very ...
2
votes
1answer
41 views
Thread-safety based on object value
I need to create thread-safety on a Web-API method, but only when two requests containing the same property value are ran simultaneously.
I have created a mix of WaitHandles and a ...
2
votes
0answers
30 views
Shortening critical sections in thread-safe (unbalanced) Binary Tree [closed]
I'm implementing a set of thread-safe functions that update and search an unbalanced binary tree with Pthreads (see The Linux Programming Interface: Exercise 30.2).
It's easy to implement a working ...
5
votes
1answer
176 views
Java Matrix multiplication using Multithreading
I am trying to achieve matrix multiplication using the concept of concurrency and cyclic barrier.
Here is the code snippet:-
...
0
votes
0answers
66 views
BlockingQueue with unique elements in Java
This answer on Stack Overflow includes an implementation for a Java BlockingQueue with unique elements. I changed it and included it in a project:
...
5
votes
3answers
146 views
Concurrently reading a Map while a single background thread regularly modifies it
I have a class in which I am populating a map liveSocketsByDatacenter from a single background thread every 30 seconds inside ...
1
vote
2answers
49 views
Simplified LogService (from concurrency in practice) with shutdown feature
Brian Goetz provided following code of LogService with shutdown feature:
...
2
votes
2answers
242 views
Running multiple producer and single consumer in a multithread environment
I have a below class in which add method will be called by multiple threads to populate messageByChannelReference concurrent ...
0
votes
1answer
55 views
2
votes
0answers
35 views
Concurrent ObjectPool using ConcurrentLinkedQueue
Main ObjectPool Class: It uses atomic operations and a concurrent linked queue to achieve the best performance compared to Apache commons pool. I want to make sure there are no concurrency issues even ...
0
votes
0answers
43 views
Queue that permits at most X simultaneous operations
I ran into this once (permits=N) and then again today (permits =1) where I only want 1 to N operations running simultaneously. One example comes from firing into a state machine (the permit=1 example)...
6
votes
1answer
189 views
RabbitMQ wrapper to work in a concurrent environment
I'm developing a common library for my organisation that will be used across different services by different teams. The library is a simple wrapper for RabbitMQ.
Some services will only be producers, ...
2
votes
0answers
90 views
RCU in C++11 using std::shared_ptr and a little more
Here's some code I wrote to solve a problem at the server I'm working on. Is this valid? I've tested it, and it works, but I would like some opinions on this.
It's basically a ...
1
vote
2answers
422 views
1
vote
0answers
42 views
Wikipath stack in Java - Part I/IV - The search algorithm
I am working on the following small software stack:
The objective of the entire stack is to search for shortest paths in the Wikipedia article graph as fast as possible. As of now, I rely on two ...
0
votes
0answers
246 views
Ruby thread pool implementation
I'm in the process of adapting the simple thread pool described here to my application. I'm new to concurrency in Ruby, but here is what I have so far:
...
1
vote
1answer
101 views
Multithreaded Producer-Consumer pattern
I have Producer Threads A, B and C producing 3 different types of events Events A, B and C respectively. The Consumer thread can ...
-2
votes
1answer
36 views
Capture some state in Haskell
I want to capture some state in a Haskell function. For instance, I have many thread trying to print on the console and I want the to play nice with each other. So I want to have some XX to make the ...
2
votes
3answers
1k views
C++11 Blocking Queue learning exercise
As part of my own C++11 learning exercise I have implemented this Blocking Queue using the new C++11 thread API. One of the aspects I would like to improve is efficiency i.e. in the ...
2
votes
0answers
45 views
Methods to add and check elements in a Bloom Filter
I have a working Java implementation of Bloom Filter.
These are the methods to addElement and check for an element.
...
2
votes
1answer
3k views
Reader-writers problem using semaphores in Java
I have written my own solution to the Reader-Writers problems using semaphores based on the psuedocode from Wikipedia. I would like to gauge the correctness and quality of the code.
...
4
votes
1answer
64 views
Multiple Persons enter room simultaneously and exits after specific interval of time
Here is the link to git repo of my application I am currently implementing just to have better understanding of OOP as well as learning Concurrency (Atleast a try :D)
What is the whole ...
0
votes
1answer
508 views
Design of thread pool reuse with Executors.newFixedThreadPool in Java
In my application I have code which should run every hour on a new items and execute some expensive operation with multithreading:
...
6
votes
1answer
101 views
Can my cache be more thread safe?
I have been working on a cache that can handle multiple reads at the same time, but the write is blocking.
Is this code overkill by using both a ConcurrentHashMap ...
2
votes
1answer
4k views
Executor Service with Blocking Queue
I did not find a single working implementation of using an Executor Service with a Blocking Queue. So , I have come with with a working sample. Thoughts?
...
5
votes
3answers
595 views
Simple Java task scheduler
The task is pretty simple: implement a timer that executes tasks when the next event takes place. I created a task scheduler based on a priority queue.
A new thread is created for ...
4
votes
2answers
409 views
Parallel foreach with configurable level of concurrency
The purpose of this code is to let me loop over 100 items (up to MAX_CONCURRENT at a time), performing some action on them, and then return only once all items have ...
5
votes
1answer
76 views
Lock implementation using atomics
I was recently given an interview and was asked to write my own lock implementation using atomics, but not necessary reentrant.
I didn't answer the question, but at home, I wrote this code. Please ...
10
votes
1answer
496 views
“Barbershop”-esque Semaphore Implementation
Recently, I submitted a project that simulates a barbershop-style problem; the task was to create a Hotel that contained guests, front-desk employees, and bellhops. ...
0
votes
3answers
299 views
Implementing multiple Producer Consumer using custom Blocking queue [closed]
I am trying to implement multiple producer multiple consumer problem using a custom blocking queue. The requirement is that:
If the queue is not full, all the producers should be able to produce ...
6
votes
2answers
3k views
Printing even and odd using two concurrent threads
Please review the code below where thread Odd prints all odd numbers from 1 to 9 and thread Even prints all even numbers from 2 to 8. I tested it and it works but can we improve it from design or ...
6
votes
1answer
48 views
Class managing queuing updates from another thread, Version 2
This is an updated version of: Class to manage updates coming in from another thread
Managing updates from other threads into Swing is a hard problem. In MVC design, if you don't want to have the ...
5
votes
2answers
70 views
Class to manage updates coming in from another thread
Managing updates from other threads into Swing is a hard problem. In MVC design, if you don't want to have the Presenter be responsible for Thread safety, you can end up with deadlock issues, and also ...
2
votes
1answer
53 views
-2
votes
2answers
141 views
5
votes
2answers
1k views
Queue for distributing tasks between threads
I implemented the following class to dispatch std::function<void(void)> objects to a thread pool. Multiple threads will block on the pop call until a task is ...
4
votes
1answer
208 views
Multithreaded scoreboard for different levels
For an assignment I had to create a highly multi-threaded scoreboard for a multi level game. So every time a user adds a score if the level doesn't exist, it gets created ad-hoc.
Important point: a ...
5
votes
1answer
501 views
A Stream wrapper that executes all writes asynchronously
I wanted to make a Stream that can wrap another stream and buffer all writes, to increase performance; comparable to the ...
3
votes
1answer
241 views
Implementation of FastICA in multithreading approach
I am to implement a parallel version of FastICA, so I implemented the serial version of FastICA.
Now this is the architectural diagram of how it is going to parallelize. I just coded a basic ...
6
votes
1answer
716 views
C++ concurrency library
I started a C++11 library of concurrency primitives in order to
study and compare their performance;
provide high-quality implementation of those to use in my projects.
Its main target platform is ...
3
votes
2answers
2k views
ArrayBlockingQueue: concurrent put and take
I have implemented an ArrayBlockingQueue (put and take) on the lines of LinkedBlockingQueue i.e using two locks so that my take ...
4
votes
1answer
5k 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
162 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 ...
0
votes
2answers
173 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 ...
2
votes
1answer
130 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:
...
8
votes
1answer
3k 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 ...
1
vote
1answer
239 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.
...
1
vote
2answers
148 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 ...