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.
463 questions
0
votes
0
answers
53
views
ReadWrite Lock compatible with coroutines
A while ago I wrote for my own needs a (non-reentrant) read-write lock for kotlin's coroutines. I got no reactions on the relevant github thread. I think it's a nice code, so I thought I'd share it ...
1
vote
1
answer
65
views
Generate Serial number based on column value in sql server
I have table called cash_voucher it has some columns.
I want to generate voucher number based location id.
I mean generates voucher numbers starting from 1 for each location
For example location id is ...
1
vote
2
answers
167
views
ProducerConsumerSimulation.java: practicing concurrent programming in Java
Intro
This time, I was in the mood for concurrent programing (ProducerConsumerSimulation.java). To this end, I have ended up with the code below. My primary concerns are:
Class design is trash,
The ...
2
votes
1
answer
100
views
Multithreaded Merge Sort Using ForkJoin Framework
I've implemented a multithreaded merge sort using Java's ForkJoin framework, and I wanted to gather feedback on its correctness, efficiency, and scalability.
Here's my implementation:
...
8
votes
2
answers
338
views
Multi-producer, multi-consumer blocking queue
Introduction
This is a queue that allows many producers to simultaneously write their items and many consumers to simultaneously read theirs. It's useful when construction and/or consumption could be ...
3
votes
1
answer
169
views
Amount Transfer Between Different Accounts - Improved Version
This is an improved code version for Amount Transfer Between Different Accounts
Welcoming any further improvements for this.
...
5
votes
2
answers
958
views
Reduce String Length With Thread Safety & Concurrency
I implemented the below URL Shortener class. Used ConcurrentHashMap to handle concurrency.
Short URL building logic may not be optimal, but it ensures that only ...
3
votes
2
answers
230
views
Data pipeline that handles errors and cancellations
I have code that concurrently reads data from a stream, processes elements, and writes the data to another stream. Each of these individual operations may fail, in which case I want processing to halt ...
1
vote
1
answer
69
views
Distributed locking with fencing token implementation in Golang
I was reading about the implementation of distributed locks where we need to verify the lease using a fencing token as per this article - https://martin.kleppmann.com/2016/02/08/how-to-do-distributed-...
2
votes
2
answers
170
views
A thread-safe performant Money Transfer API in Java
This is a popular interview question. It is meant to be done within 30 minutes. The task is to implement a thread-safe performant Bank Account API that allows to transfer, deposit, withdraw and check ...
7
votes
2
answers
1k
views
A thread-safe performant URL Shortener in Java
This is a popular interview question. It is meant to be done within 45 minutes. The task is to implement a thread-safe performant in-memory URL Shortener.
My implementation is based on two maps that ...
5
votes
3
answers
150
views
Time based cache for single element
The container should be thread safe and provide lazy load of data, and cache the data for set period of time.
...
2
votes
3
answers
158
views
Simple rwlock implementation in C
Can someone please review my rwlock implementation to see if there are any issues with correctness (hopefully not), give any feedback on how to write good C code etc, design patterns which could be ...
4
votes
1
answer
78
views
Blocking lock for dpkg
My deployment and configuration process entails multiple processes trying to invoke dpkg on my VM at the same time. While dpkg has a locking mechanism, it causes anyone not holding the lock who is ...
2
votes
2
answers
260
views
Circular Queue Producer Consumer with Mutex and Condition Variable vs. Sempahore
How can I optimize the performance of the code below? Destruction of the condition variable at the end of main blocks, not sure why this behavior is occurring. Is it possible to remove some of the ...
1
vote
0
answers
116
views
Tkinter threadpool with callback implementation - alternative approach feedback
This is an attempt to create a usable alternative to the "normal" method of implementing concurrency with tkinter. The "normal" method seems to be by pro-actively polling a result ...
2
votes
1
answer
297
views
High-write low-read thread-safe counter
I need a thread-safe counter that will see frequent increments but will be rarely read. This counter will be used to emit metrics, for example, the hit rate of a ...
2
votes
1
answer
886
views
Parallel handling db queries is very slow in C#
I have SignalR app that publishes sent messages to Redis. My console app subscribe to channel where these messages are sent, deserializes it and saves in database.
Problem is with handling these ...
6
votes
1
answer
955
views
Simple, fool-proof pattern to execute tasks in parallel
Assume I have a type task_info that stores the task-specific data needed to execute the task. A std::vector of those is built ...
1
vote
1
answer
264
views
Lock-free implementation of getAndUpdate() using atomic CAS (Compare-And-Swap) operation
We have the following class written in Kotlin Native with the new Memory Manager (which doesn't require to freeze objects):
...
2
votes
1
answer
1k
views
Concurrently write results to SQLite database
The goal is to run a function compute in parallel on many inputs (10**6 in total, say) and store the results.
Each call to ...
1
vote
1
answer
199
views
A producer (mapper) and consumer (reducer) problem with concurrency in go with race conditions
Link to go playground https://go.dev/play/p/ctQDpDW6pui
This code has been based on suggestions and conversations in this thread here
Architecture:
A read method creates a channel shared with ...
2
votes
1
answer
229
views
Distributed lock service implementation in Golang
I have multiple E2E tests (written in Java) which share login details, each test during runtime will query the locker API for login details which is running on its own dedicated server.
Below is my ...
4
votes
1
answer
899
views
Thread Safe Queue
I have a thread safe queue in my library c9y. It is generally used as a task queue in the task_pool class, but in can be used for any producer / consumer problem.
queue.h
...
4
votes
1
answer
613
views
Golang HTTPS certificate expiry checking CLI tool
I am a beginner at using Golang, I would like advice about the following program. It is a CLI tool that can check the expiration dates of HTTPS certificates concurrently. I have only used the standard ...