Questions tagged [readwritelock]

ReadWriteLock is a structure of the two locks. From these, one locks for reading (multiple threads can access, none can modify) and another for write access (only one thread can access and also modify at time).

In Java, ReadWriteLock is a very abstract interface which provides functionality to synchronize between multiple readers and one exclusive writer.

It just assumes some structure that contains two locks. Serious problems with this interface are unlikely. If you ask something about it, probably you mean ReentrantReadWriteLock, the implementation.

Related tags:

96 questions
0
votes
0 answers

Handle Hash Collison in Stripe Read Write lock

We are using stripe lock for one of our implementation. We take readlock on some final constant and a writelock on key. We noticed that we ran into a deadlock because hash code of two different keys turned out to be same. And hence it is like…
arun
  • 388
  • 2
  • 17
0
votes
0 answers

Why do read locks and write locks handle expiration time differently in Redisson?

Here are the lock scripts of read lock and write lock in Redisson. lock script of read lock lock script of write lock As we can see from the script, if read lock is reentrant and lock again, the expire time of the lock will be reset to the…
chaos
  • 1,359
  • 2
  • 13
  • 25
0
votes
1 answer

Read/Write lock required when writing to a std::map in a separate thread

I've implemented a systemd service in C++ that automatically starts when the system boots. The goal of this service is to acquire system resources and make them accessible via an API. One of these resources is the cpu load. I've implemented a…
Xershy
  • 177
  • 11
0
votes
1 answer

c++ double shared_lock freezes the program on windows

When I am learning shared_mutex in C++17, I find a weired problem. If I call shared_lock twice in one thread, and call unique_lock in another thread, then my program will freeze. Like this: std::mutex mutex; std::shared_mutex s_mutex; int i =…
0
votes
1 answer

Order Matching System Design : how to design an efficient and secure crypto account system

Context I am working in a crypto exchange company as backend engineer. Recently, we are facing a performance issue in our matching system. When user's order got match, system will deduct or add order's amount to their account. This process will lock…
0
votes
1 answer

Dispose ReaderWriterLockSlim after ExitWriterLock

I have a function to clean up some objects as well as the ReaderWriterLockSlim. But I need the ReaderWriterLockSlim to lock as writer lock to prevent the other thread read the data while I am doing the clean up. ConcurrentDictionary
0
votes
1 answer

How to read a variable without lock in Python threads?

I am using Python threading to do some jobs at the same time. I leave the main thread to perform task_A, and create one thread to perform task_B at the same time. Below is the simplified version of the code I am working on: import threading import…
SHM
  • 61
  • 1
  • 8
0
votes
1 answer

Write locks have priority to access the critical region in a java readWrite lock?

I need writers threads to have priority to access critical region over readers threads, can I use the ReadWriteLock interface to do this?
Juan Gil
  • 37
  • 7
0
votes
1 answer

Where could be any problems in the program and how i solve them with using lock() and unlock()?

The following piece of pseudo-code shows a typical reader / writer scenario: string document; string::size_type length = 0; write() { while (true) { string text = readFromKeyboard(); document.append(text); length =…
0
votes
1 answer

Can SRW Lock be used as a binary semaphore?

Slim Reader/Writer (SRW) Locks is a synchronization primitive in Windows, available starting from Windows Vista. Name and interface suggests that it should be used as non-timed shared non-recursive mutex. However, it is common to use it as…
Alex Guteniev
  • 12,039
  • 2
  • 34
  • 79
0
votes
1 answer

Is Windows' AcquireSRWLockExclusive recursive?

I need to use read-write lock, but I would also like to be sure that the lock is recursive in both read and write mode, so that calling function that uses it on the same thread doesn't lock. I found nothing on MSDN docs. Maybe it's hidden somewhere…
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
0
votes
1 answer

python multiprocessing read write lock

I have multiprocessing python code using multiprocessing.Lock. I would like to change it to have read-write lock instead of simple lock. I was looking for an implementation of it but the only multiple readers / single writer locks I have found in…
Diana
  • 86
  • 6
0
votes
1 answer

correct usage of readwrite locks

I have a requirement which is as below : 1) A class which has all static methods and a static list. This list stores some objects on which I perform some operation. 2) Now this operation is called from multiple threads. 3) this operation call is not…
Onki
  • 1,879
  • 6
  • 38
  • 58
0
votes
2 answers

Read lock while Writing

I need help in understanding the below code : private Predicate composedPredicate = null; public boolean evaluate(Task taskData) { boolean isReadLock = false; try{ rwl.readLock().lock(); isReadLock = true; …
0
votes
1 answer

How to Synchronize File operation using java? Synchronized or Lock?

I created a application for reading and writing to a remote location property file using JSCH library. I want to synchronize the write operation . This is my code , class WebApp{ private String webappName; private boolean isQA = false; …