Skip to main content

Questions tagged [locks]

Locks are a synchronization mechanism for enforcing limits on access to a resource.

Filter by
Sorted by
Tagged with
1 vote
4 answers
273 views

Context I'm working on a client-server-agent application, where server distributes tasks supplied by clients over agents. Server is passive, all communications are initiated by clients and agents. ...
Basilevs's user avatar
  • 4,507
1 vote
1 answer
345 views

I'm thinking about implementing garbage collection efficiently by protecting the structure that tracks allocations using reader-writer lock. However, I'm worried memory semantic may invalidate the ...
DannyNiu's user avatar
  • 374
1 vote
2 answers
356 views

Over and over I am faced with a similar problem: I have to perform two actions that are mostly unrelated, except that they need to share a mutex lock, at least for a moment. For example: void action() ...
CygnusX1's user avatar
  • 257
5 votes
2 answers
2k views

Recently I've come to discover that I've inherited one of the internal auxilliary programs used. I've made a few minor fixes and features to improve it in the past, but now I've been given a major ...
rdi_pck's user avatar
  • 61
-1 votes
1 answer
417 views

Edit #1 I believe that I misrepresented my intent when writing this question by focusing too much on the issues that have arisen from our misuse/misunderstanding of locks. I am making this edit to try ...
notphilphil's user avatar
4 votes
4 answers
4k views

I'm an experienced Software Engineer but very weak in concurrency because of no prior experience in that. I've been interviewing with several companies in which I was asked similar kind of questions ...
SherlockHolmesKePapa's user avatar
-1 votes
1 answer
2k views

I'm working on a web application using Spring (Java and JPA + Hibernate) and I was wondering if there is a way of locking a MYSQL table and then when another web service (or even another thread from ...
Jordi Pagès's user avatar
2 votes
0 answers
315 views

Since I am working in a multi-instance microservice environment, I came accross a problem with making some operations being performed at most by one of the running instances at once. The solution ...
PJDev's user avatar
  • 129
1 vote
2 answers
319 views

Problem In my application a user can lock a set of related aggregate roots to work exclusively on them and to avoid the usage of an invalid set of objects later in the process (by other employees). ...
deamon's user avatar
  • 886
1 vote
2 answers
1k views

I am calling a payments API to send a payment. At the same time, I need to mark the payment as sent in my database. If I call the API first, then the database crashes, the payment will be sent twice. ...
Lucien's user avatar
  • 121
1 vote
2 answers
357 views

A simplified version of my problem looks like this: the database contains two tables: one contains account balances (Accounts) the other contains account withdrawal and deposit requests (Requests) ...
Alexey's user avatar
  • 277
7 votes
3 answers
740 views

We have a REST API Get request which downloads a file from the server. This file needs to be updated whenever there is a latest version. Currently this is done by deleting the existing file and moving ...
Anjo's user avatar
  • 215
7 votes
5 answers
9k views

in read-write locks, why do we need read locks since processes can read a file at the same time? Would only a write lock suffice? Thanks.
Tim's user avatar
  • 5,565
0 votes
2 answers
376 views

this is a highly theoretical question about my parallelization approach. First of all, I want to inform everybody that I do not claim that I am the 'inventor' of that approach but I couldn't find any ...
Damian Grzanka's user avatar
-3 votes
1 answer
91 views

A program I'm developing has two threads running similar but different task: thread1: timer1.start() writeToExternalDB1(consumedData) timer1.end() thread2: timer2.start() writeToExternalDB2(...
zonyang's user avatar
  • 103
-1 votes
1 answer
520 views

Yes, I know, the question title is a bit provocatory. But let me explain. I needed to execute a sequence of async tasks in JavaScript. They are async because I need them to be non-blocking, but I ...
Christian Vincenzo Traina's user avatar
2 votes
2 answers
2k views

As I am moving a part of the monolith app logic to a microservice, I am standing before a problem with scalability. Currently, the main monolith runs on different instances, and has some scheduled ...
hc0re's user avatar
  • 129
4 votes
3 answers
1k views

In the context of a multiuser database desktop application, the concurrency problem has to be considered. Many articles focus on two models: optimistic and pessimistic locking. In pessimistic locking ...
AgostinoX's user avatar
  • 849
0 votes
2 answers
4k views

We have a set of micro-services that are functionally dependent and have intertwined validation logic. e.g. consider 'Credit-Card' service and 'Loan' service. When user has a credit card then loan ...
Sekar's user avatar
  • 133
17 votes
3 answers
8k views

I'm trying to build a C# application that sends notifications from the server to its users (a mobile app). Since each user can have its notifications collection changed by any thread, I have to lock ...
Idov's user avatar
  • 279
0 votes
1 answer
228 views

I'm working on adding Approval workflows around our system which manages CRUD operations for our business item. Till now, I have been using an optimistic locking strategy to handle race conditions ...
MadN's user avatar
  • 47
2 votes
2 answers
2k views

We have a system where multiple consumers get messages out of a queue (currently implemented with a database). The messages have an order field. All messages of one particular order should be ...
Pieter-Jan Van Robays's user avatar
2 votes
2 answers
157 views

I've seen this approach several times, both in async and multithreaded code. A counter is used to track asynchronous behavior or thread behavior - whenever a new action is started, the counter is ...
Dan Monego's user avatar
1 vote
2 answers
73 views

Let's say process A has an exclusive lock on some shared resource. Is there a way to ensure that after it completes execution, Process B will definitely get the lock (as compared to say, process C ...
rahs's user avatar
  • 115
4 votes
4 answers
3k views

I'm improving/expanding a somewhat large code base, and I've introduced multithreading into it. But with the possibility of introducing code that could deadlock, which is nigh impossible to test for ...
Carl Colijn's user avatar
3 votes
1 answer
400 views

I got this question on an interview the other day and was clueless to what the best practices are for solving it. It's the issue where you have to transfer money between two systems and want to avoid ...
Dave's user avatar
  • 139
1 vote
1 answer
289 views

I have a question concerning the "Uncommitted Read" Isolation Level under DB2 DBMS for z/OS. In this article https://www.ibm.com/support/knowledgecenter/en/SSEPEK_11.0.0/perf/src/tpc/...
Monty Burns's user avatar
6 votes
1 answer
1k views

While developing my own logging library, I studied the source code of the standard logging module of CPython. One of its features is that handlers are thread-safe. One can write logs to a file from ...
Delgan's user avatar
  • 376
3 votes
2 answers
5k views

I'm trying to figure out the best solution for the below. Any help would be great. So basically I have a service (that can be scaled horizontally), which listens on a queue. Every message received ...
Alan-Old's user avatar
1 vote
1 answer
161 views

Some sites, like theater ticket reservations, place a limited-time hold on the item , while the order is being processed. As soon as you select the seat and proceed to pay, Seat is reserved say for 10 ...
user3198603's user avatar
  • 1,896
0 votes
2 answers
606 views

Consider this simple example: Tables (in a restaurant) can be booked for a period. Business constraint: No two table bookings for the same table may overlap in time. How might one prevent business ...
Jesper's user avatar
  • 123
2 votes
1 answer
447 views

I have a shared resource in a database that is used by clients C1 and C2. Before the resource is read by C1, C1 should mark the resource as leased so that C2 will know it is busy. C1 will do some ...
span's user avatar
  • 415
2 votes
2 answers
559 views

I am building a webapp (Angular frontend, Groovy/Spring/Hibernate/MySQL backend) that will allow users to compete against each other over certain activities. Each activity will have 1 winner and 1 ...
smeeb's user avatar
  • 4,970
4 votes
1 answer
2k views

I am trying to build a movie ticketing system. But I am not able to figure out how to solve the below use case: Let’s say there are 10 seats namely S1,S2,S3,S4… S10. Now let’s say that User1 had ...
madan's user avatar
  • 127
2 votes
3 answers
2k views

I know that transactions use locks. It is claimed that actors liberate us from shared state and locks make sure all crashes are the same as clean shutdowns: this can be done through practices such ...
Val's user avatar
  • 367
3 votes
2 answers
153 views

I'm designing a system that like the majority of social related application has posts, people can like the posts and comment on them. And also like the majority of the applications the users can see ...
Lucas Piske's user avatar
4 votes
1 answer
6k views

In a multi-threaded environment, we must consider concurrent access to writable resources. A common approach is to use Monitor or its shorthand form lock. Task is at a different abstraction level ...
Bernhard Hiller's user avatar
4 votes
1 answer
2k views

We have a MVC Web API that is called to write transactions for a specific amount, where the amount is debited or credited to a user's balance. This records the balance pre-transaction (PreAmount), the ...
Derreck Dean's user avatar
2 votes
2 answers
408 views

I have an ArrayList of objects that may be added/deleted/updated via REST calls. In order to prevent issues that may result from concurrent accesses, will a ReadWriteLock be appropriate, and efficient?...
SVN600's user avatar
  • 61
4 votes
1 answer
1k views

Background Okay, so let's say I have some high priority (ThreadPriority.Highest) thread t which needs to enter a critical region in order to consume some data. I will use the following code snippet ...
Snoop's user avatar
  • 2,758
3 votes
1 answer
2k views

I see a lot of programs that does write a pidfile, and check at boot its existence. And this is good. But many application does not start even if they check that the pidfile exists, yes, but no ...
Marco Sulla's user avatar
9 votes
5 answers
1k views

While I was reading a research paper on concurrency named Software and the Concurrency Revolution (html version). I came across following lines: Unfortunately, although locks work, they pose serious ...
user avatar
0 votes
1 answer
214 views

We had a bug caused by ruby workers (4 processes, 1 thread each) doing batching records using a legacy mongodb as the store. The race condition was around whether the batch was full or not; with one ...
kreek's user avatar
  • 317
4 votes
2 answers
863 views

The definition of a deadlock is when two or more threads cannot complete their execution because they are mutually blocked and waiting for something from the other thread(s). Is there a similar term ...
Ian Newson's user avatar
3 votes
1 answer
654 views

I have a web application written in C# which uses external dll written in C++. Communication between clients (web browsers) and a web application is done using SignalR. For communication between web ...
rrejc's user avatar
  • 141
1 vote
0 answers
54 views

I need to show a refreshable/searchable list of items and update/add-to it whenever an event is published. How do I make sure no events are lost while refreshing/searching is happening? Some sort of ...
Den's user avatar
  • 4,887
43 votes
5 answers
7k views

Is spinlock and polling the same thing? Wikipedia: a spinlock is a lock which causes a thread trying to acquire it to simply wait in a loop ("spin") while repeatedly checking if the lock is ...
Lord Loh.'s user avatar
  • 1,787
9 votes
2 answers
6k views

I am new to Akka and actor framework - I am sure I am missing something obvious, please accept my apologies in advance. I keep reading that one of the main points to choose Akka is the way it manages ...
abx78's user avatar
  • 415
4 votes
2 answers
691 views

There are many different types of charts and diagrams we use to formalize scenarios and study them tangibly -- activity diagrams, sequence diagrams, etc. I've been faced with a pretty complex locking ...
Sean Allred's user avatar
3 votes
1 answer
156 views

I have a database accessed by an several servers, let's call them workers. These workers take one item from the database, do some operations on it and then update it back into the database. The ...
nmat's user avatar
  • 863