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
1
vote
2 answers

need read-write lock in objective c or c

I can't seem to find any read-write locks for Objective C. This is for iphone dev. Any ideas? The appendix in this paper has some code, but it is incomplete.
Jacko
  • 12,665
  • 18
  • 75
  • 126
1
vote
0 answers

How to replace a concurrently instance without losing data?

I have many threads who save the state and one thread that logs the state. I'd like to not lose data, which means to always log the latest state. The solution I have is to use a read-write lock when replacing/clearing the stats collection, which…
AlikElzin-kilaka
  • 34,335
  • 35
  • 194
  • 277
1
vote
1 answer

Write-locked file sometimes can't find contents (when opening a pickled pandas DataFrame) - EOFError: Ran out of input

Here's my situation: I need to run 300 processes on a cluster (they are independent) that all add a portion of their data to the same DataFrame (they will also need to read the file before writing as a result). They may need to do this multiple…
Marses
  • 1,464
  • 3
  • 23
  • 40
1
vote
1 answer

What's wrong with my usage of ReentrantReadWriteLock?

I have a trouble with ReentrantReadWriteLock. Thread hangs when I trying to wipe file. I have a scheduled read operation and eventual write operation(when user presses the button) which use one instance of ReentrantReadWriteLock. Next code looks…
1
vote
0 answers

implementing a c# read write lock where some reads produce writes

I have to implement some .Net code involving a shared resource accessed by different threads. In principle, this should be solved with a simple read write lock. However, my solution requires that some of the read accessions do end up producing a…
Alberto Anguita
  • 103
  • 1
  • 11
1
vote
1 answer

Resolving Whoosh IndexingError: Writer is closed

Different from python whoosh IndexingError when interrupted, I've not interrupted any commits but the IndexingError occurs when creating a new index: import uuid import os from whoosh.index import create_in from whoosh.fields import * from…
alvas
  • 115,346
  • 109
  • 446
  • 738
1
vote
1 answer

Lockmode PESSIMISTIC_WRITE in criteria vs select for update

Is there any significant difference in performance in using PESSIMISTIC_WRITE as LockMode in hibernate criteria as an alternative for Select for update query. Use case involves following points: Restrictions on values in multiple columns like…
1
vote
0 answers

Is there a structure for read or write_lock in a database?

Say I want to write (update) something that exists in many tables of my database like an EMPID, and I want to change all the EMPID from having 4 numbers to 5. How would you write this? Is it a normal update query with a write_lock at the start and…
Luna
  • 1
  • 3
1
vote
1 answer

How to implement A Cache by using ReadWriteLock in java?

My main question is "Do I really need recheck the value in the following code"? The following code describes how to implement a cache by using ReadWriteLock. public class ReadWriteLockCache { private Map cache = new HashMap
scugxl
  • 317
  • 4
  • 15
1
vote
1 answer

Thread safe destruction of Read-Write Lock in C

I'm trying to write a thread-safe read-write lock in C using POSIX semaphores. You can see the current state of the source code here. I followed this to create a readers-preferred lock. The problem is I would like to handle the destruction of the…
JasonPap
  • 98
  • 6
1
vote
1 answer

How to replace a non-synchronized concurrent list or array atomically

I have a List read (iterated through) many times and by multiple threads but updated rarely (reads are more than 50,000 times more numerous). EDIT: in fact, an array would suffice in this case, instead of a List. When the list is updated, it's…
1
vote
1 answer

Read-write synchronization class implementation

I am writing a read-write synchronization class, and would like some advice on what I to do next. For some reason, it sometimes allows a Read to happen in the middle of a Write, and I cannot find the reason. This is what I want from this…
Miguel Angelo
  • 23,796
  • 16
  • 59
  • 82
1
vote
3 answers

Can I read from a SQLite db while writing to it on the iPhone?

Is it possible to read from a SQLite db while it's being written to? I'm aware that access is blocked for writes when it's being written to, but is that the same for reads?
Jasarien
  • 58,279
  • 31
  • 157
  • 188
1
vote
3 answers

Thread safety of std:map and std:set

Possible Duplicate: Do I need to protect read access to an STL container in a multithreading environment? If some thread reading :set or :map when another thread writing to this set or map, what will happen? Exception? Now i use read-write locks,…
RomanKarpuk
  • 57
  • 1
  • 7
0
votes
0 answers

performance differences between shared_mutex.lock and shared_mutex.lock_shared?

The scenario is: I have two shared_mutex for two shared variable a b, to prevent deadlock, if thread A get mutex_a but cannot get mutex_b, thread B get shared_mutex_b but cannot get shared_mutex_a, in this case, should thread A abandon mutex_a or…
Xin_Wang
  • 1
  • 1