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.
concurrency
23,075
questions
-1
votes
0
answers
43
views
How to process a (near) infinite list in Java?
I am using an object storage provider that does not implement a recursive delete. When someone comes in and asks to delete a bucket, I have to manually empty the bucket. I basically have two methods ...
0
votes
1
answer
25
views
Recursive use of ProcessPoolExecutor is Hanging
Problem
I'm trying to use a ProcessPoolExecutor with recursive calls, but it doesn't work. I created a minimal example below
from concurrent.futures import ProcessPoolExecutor
from time import sleep
...
0
votes
0
answers
10
views
Concurrency Control Mechanism For Dataframe Processing In Django WebApp
I have django webapp where processing data directly on pandas dataframe without using django model. now, i want to make this operations concurrency control for multiple processing requests ...
1
vote
0
answers
10
views
Concurrent Requests Creating Duplications for Users
I am facing an issue with concurrent requests resulting in duplicate entries. Our system checks whether a user exists and creates a new one if not, using middleware. However, when multiple concurrent ...
0
votes
0
answers
22
views
Why is a Thread-Scoped Bean Injected Instead of a Default-Scoped Bean in Spring Boot?
I recently made a change to my Spring Boot project. I initially had a bean without a specific scope. Due to an implementation that uses threads and the occurrence of concurrency issues, I needed to ...
0
votes
0
answers
25
views
Problem with concurrency while updating data in DB using Quartz .NET and EF Core
I want to introduce horizontal scaling instead of vertical in my app.
Now we are using Quartz .NET for background tasks, but in non-clustered mode, just 1 instance.
So I found ability to do horizontal ...
1
vote
0
answers
12
views
Modifying object outside RxJava stream
Is it correct to modify object inside reactive flow, when it was defined outside of it?
Example:
public Single<MyDto> createDto() {
MyDto dto = new MyDto();
return Single.just(“...
1
vote
1
answer
88
views
Java concurrency problem by multi-thread not occured and automatically synchronized
I’m trying to test a multi-threaded concurrency problem.
What I expected is that the result should be less than 0 (not always but sometimes), because it is not synchronized.
Notice the pair of println ...
-1
votes
0
answers
18
views
Keycloak concurrency issue while updating roles of a user after authentication with external server
I'm facing an issue with Keycloak while using an external user storage provider. The problem occurs when the same user tries to log in concurrently on multiple devices. Here are the details:
Scenario:
...
0
votes
1
answer
44
views
Can CUDA Thrust Kernels operate in parallel on multiple streams?
I am attempting to launch thrust::fill on two different device vectors in parallel on different CUDA streams. However, when I look at the kernel launches in NSight Systems, they appear to be ...
0
votes
0
answers
20
views
Assertion Failure: Block Expected on Main Thread in Swift macOS App Using DispatchQueue [duplicate]
A user is experiencing a crash in my macOS app. It was written in Swift and developed using Xcode. The crash report indicates an assertion failure related to dispatch queues, specifically stating that ...
0
votes
1
answer
55
views
Why does the following example with condition variables as synchronization primitives have a data race? [duplicate]
Golang documentation for the condition variables states the following:
In the terminology of the Go memory model, Cond arranges that a call
to Broadcast or Signal “synchronizes before” any Wait call ...
0
votes
1
answer
45
views
What would be the best way to handle many I/O connections in GoLang? [closed]
I'm trying to make a game server in Go that is planned to handle 1~2k connections at a time. The server will read/send tcp packets. The question is when do I need to use a goroutine? Do I use one ...
1
vote
0
answers
38
views
Key Range Locking when Serializable isolation is used in POSTGRESQL
I have an events table where each POST / PUT request is performed under transaction with Serializable Isolation to ensure that no two users tries to books same event spot.
But the negative impact of ...
1
vote
0
answers
48
views
How to handle a DB concurrency conflict when using a SumAsync() call?
I have a site that registers students to classes and uses a "Token" system as payments to register. Ex. 5 tokens to register.
When a payment is made to register for a class, I create 2 rows (...
0
votes
1
answer
90
views
Swift 6: Error: Task or actor isolated value cannot be sent
I'm trying to resolve a compilation error: Task or actor isolated value cannot be sent when using Xcode 16.0 beta 3 with Swift 6 and Complete Concurrency enabled. My code:
import SwiftUI
@...
1
vote
1
answer
91
views
Is optimistic locking safe from race condition in case of concurrent transactions? [closed]
When reading about optimistic locks, I have come across examples which use versioning like below
UPDATE table SET column1 = new_value1, version = version + 1 WHERE id = some_id AND version = ...
0
votes
1
answer
36
views
c++ concurrency problem using semaphore: print in order
As an c++ concurrency exercise, I want to print letters A B C in that order, using semaphore. Here's my code:
binary_semaphore sem[] = { binary_semaphore(1), binary_semaphore(0), binary_semaphore(0) };...
0
votes
1
answer
26
views
GRPC Java MAX_CONCURRENT_STREAMS vs maxConcurrentCallsPerConnection
I'm trying to understand the difference between MAX_CONCURRENT_STREAMS and maxConcurrentCallsPerConnection. I read that most servers set MAX_CONCURRENT_STREAMS to 100 as a default whereas ...
1
vote
1
answer
94
views
Passing argument of non-sendable type '(any URLSessionTaskDelegate)?' outside of main actor-isolated context may introduce data races
I am using SwiftUI and I declared the View as @MainActor to resolve some of the concurrency warnings. However, I still get the warning
Passing argument of non-sendable type '(any ...
0
votes
1
answer
35
views
Go channel sometimes not receiving the last value
I'm currently learning go channels, and I'm trying out this piece of code. It creates 10 goroutines which sends a 1000 1s each to a channel. Then another go routine receives it and adds it to a ...
-1
votes
1
answer
50
views
Using AtomicInteger as counter for List [closed]
I am learning multi threading. I have below code which implements round robin algorithm over an CopyOnWriteArrayList. List will always have a fixed number of elements let's suppose 10.
...
0
votes
0
answers
44
views
C++ main thread polling and blocking, termination on signal
I have a main thread which should do some work every N seconds (20 in this case) and wait/block/suspend in-between. However, at the same time, I want the application to stop correctly on a SIGTERM/...
1
vote
1
answer
42
views
Java CopyOnWriteArrayList add element if not exists already
I have an CopyOnWriteArrayList as my code should be thread safe.
List friuts = new CopyOnWriteArrayList<>();
I don't want to have duplicate friuts in list I cannot use Set as I want to have ...
0
votes
0
answers
18
views
Streamlit: keep fragment running while the page loads
I have a Streamlit UI with this code
import streamlit as st
import time
_LOREM_IPSUM = """
Lorem ipsum dolor sit amet, **consectetur adipiscing** elit, sed do eiusmod tempor
incididunt ...
0
votes
1
answer
83
views
ProgressView Not Updating During Data Parsing in SwiftUI
It's hard to reproduce the full code, but I'll try to explain the issue clearly.
I'm trying to display a progress bar view to show the status of parsing some data downloaded online. The function I use ...
0
votes
0
answers
47
views
Request Chunks from the peer in parallel in golang over a tcp connection
I'm building a P2P file transfer system in Go that fetches chunks of data from peers in parallel. While sequential requests work fine, parallel requests using goroutines behave inconsistently, ...
1
vote
0
answers
213
views
Capture of 'self' with non-sendable type in a `@Sendable` closure
I'm working on a NetworkService class in Swift that uses async/await and observes network state changes. I'm converting the code to Swift 6.0 and I'm getting the following error on the line inside ...
-2
votes
0
answers
91
views
Asyncronous function don't run in the correct order [duplicate]
Why is my code not running in the correct order?
I can’t figure out why my code is not executing in the correct order. My downloadData function includes and should run the following three functions in ...
1
vote
2
answers
32
views
Django ORM model 'save' method and race condition / ACID Isolation
if we examine the following code:
class SomeModel(models.Model):
...
def save(self, *args, **kwargs):
self.validate_unique()
super().save()
def validate_unique(self, *args,...
0
votes
0
answers
10
views
SubscriberContext state in case of concurrent HTTP Request in spring reactive
I have an HTTP API written in Spring Reactive which fetches user details from the datastore. I am adding the description for the API below.
@Configuration
class Routes {
@Bean
fun router() = ...
2
votes
1
answer
30
views
Manage concurrent users per single subscription
I am implementing a functionality in which user can take one subscription &** maximum 10 account can be created per single subscription but only 3 concurrent users are allowed**.
I am using ...
1
vote
1
answer
73
views
Multithreaded program not running as expected
I was trying to learn about semaphores, reading The Little Book of Semaphores by Allen B. Downey.
In that there is a puzzle:
Generalize the rendezvous solution. Every thread should run the
following ...
-1
votes
0
answers
93
views
Capture of 'self' with non-sendable type 'Type?' in a `@Sendable` closure
I have a warnings 'Capture of 'self' with non-sendable type 'Type?' in a @Sendable closure' for this code
func launchPairingAtCorrectStepAfter(timeout: TimeInterval) {
Timer.scheduledTimer(...
0
votes
1
answer
45
views
Conforming system type to a protocol with `@MainActor` isolation while disabling the concurrency check gives unexpected error
I have the following code that worked well:
protocol URLLauncher {
func open(_ url: URL, options: [UIApplication.OpenExternalURLOptionsKey: Any], completionHandler: ((Bool) -> Void)?)
}
extension ...
0
votes
0
answers
20
views
Multiple producer single consumer queue usecase
I am relatively new to Python and this is the usecase i am trying to solve as part of the learning.
There will be multiple threads calling a callback function. If the event is not set, the callbacks ...
0
votes
1
answer
62
views
Guarding tests against exit/death
I'm using googletest to test multi-threading code with std::thread. In broken code, it often happens that a std::thread is destroyed before the thread has joined, causing a program termination. ...
-1
votes
1
answer
49
views
Is it thread-safe by default to have nested CopyOnWriteArrayList?
Lets imagine I have the following code:
class ClassA {
final Integer i;
final String;
final CopyOnWriteArrayList<ClassB> l;
ClassA() { ...
}
}
class ClassB {
final ...
-1
votes
0
answers
19
views
Exception in HostObject::get for prop 'UIManager': java.util.ConcurrentModificationException - React Native
In our react native app (developed via expo with a custom dev client) we are encountering a problem. Some users have told us that very often the app crashes the first time it is launched on Android. ...
0
votes
1
answer
102
views
How to convert AdMob `GADFullScreenContentDelegate` to Swift 6 concurrency
This is a similar problem to How to convert `VNDocumentCameraViewControllerDelegate` to Swift 6 Concurrency but one warning is new, so this may require different solution.
I have the following code:
@...
0
votes
0
answers
40
views
Concurrency and Multi-threading
How can one implement a custom ReadWriteLock in Java that allows a thread to upgrade a read lock to a write lock without risking deadlock?
0
votes
1
answer
30
views
message-driven-channel-adapter - concurrent processing of messages
Issue
We have a legacy application with the following message-driven-channel-adapter configuration
<jms:message-driven-channel-adapter
id="processRequest"
destination=&...
0
votes
1
answer
75
views
How to convert `VNDocumentCameraViewControllerDelegate` to Swift 6 Concurrency
So I have this code:
fileprivate class DocumentScanDelegate: NSObject, VNDocumentCameraViewControllerDelegate {
static let shared = DocumentScanDelegate()
var compressionQuality: CGFloat = 1
...
-1
votes
0
answers
52
views
Non blocking Processbuilder output
When using ProcessBuilder, is there a true non blocking reactive way to consume the output? By true non blocking i mean not creating a thread that is blocked waiting to read, but push-based like ...
0
votes
0
answers
24
views
Adding Thread.sleep in spring boot web app adding delays to subsequent requests [duplicate]
@RestController
public class HomeController {
@GetMapping("/")
public String greet() throws InterruptedException {
System.out.println(Thread.currentThread().getName());
...
0
votes
0
answers
25
views
ThreadPoolExecutor slows down while running
I have a list of arguments that can be executed in any order. I have written one function to parse and write to an S3 bucket. The function output is a CSV file that's written to the bucket.
def func(...
1
vote
0
answers
53
views
How to reduce cache miss in SPSC queue pop function?
I am working on optimizing a Single Producer Single Consumer (SPSC) queue in C++. The following is the miniman reproducible example for my implementation:
#include <atomic>
#include <cstddef&...
0
votes
1
answer
28
views
Lambda Provisioned Concurrency showing 0 available. But I'm not using any
I have been using my AWS account for more than 4 months. Now, I need to create a Lambda function with provisioned concurrency. However, it gives the following error:
```The maximum allowed provisioned ...
0
votes
1
answer
124
views
Is this ThreadPool implementation correct?
I am new to concurrent coding and trying to implement simple ThreadPool by myself. I found this implementation on a learning website(jenkov.com) and it seems to be working fine.
However, I think ...
0
votes
1
answer
65
views
Performance in Go: Mutex vs RWMutex
There are two types of mutex in Go: Mutex and RWMutex
Mutex offers func Lock() and func Unlock().
RWMutex offers those functions plus func RLock() and func RUnlock().
From what I understand, we ...