Questions tagged [locking]

Locking allows different types of resources to be used exclusively by one process at a time.

For more information see Locks in Java

8782 questions
4
votes
3 answers

Are there any efficient (sub)tree locking mechanisms?

I have a tree T, nodes of which can be addressed by their paths (payloads of nodes contain some names that can be glued together into a path). What I would like to have is some mechanism (algorithm, auxiliary data structure etc.) that will allow,…
tkroman
  • 4,811
  • 1
  • 26
  • 46
4
votes
1 answer

How to fill a List on the main-thread using Parallel.For(..)

Imagine I have got the following Class for a student with lots of properties, lets simplify it to this: public class Student{ public Int64 id { get; set; } public String name { get; set; } public Int64 Age { get; set; } } Then on the…
Revils
  • 1,478
  • 1
  • 14
  • 31
4
votes
2 answers

Order of locks in query (postgresql)

Database has table X and tables An, Bn, Cn, Dn that inherits from X. Process 1 queries periodically data from X. Process 2 updates data in child tables. For example, to update tables An and Bn it creates new tables Am and Bm, loads data into them,…
valodzka
  • 5,535
  • 4
  • 39
  • 50
4
votes
2 answers

Exclusive lock using key in .NET

I have used the lock statement in C# to exclusively execute a piece of code. Is there a way to do same based on a key. for e.g.: lock(object, key) { //code-here } I have a method which has some piece of code that is not thread-safe, but only if the…
Brij
  • 11,731
  • 22
  • 78
  • 116
4
votes
4 answers

Can I lock rows in a cursor if the cursor only returns a single count(*) row?

I would like to restrict users from inserting more than 3 records with color = 'Red' in my FOO table. My intentions are to A) retrieve the current count so that I can determine whether another record is allowed and B) prevent any other processes…
aw crud
  • 8,791
  • 19
  • 71
  • 115
4
votes
2 answers

Postgresql: Implicit lock acquisition from foreign-key constraint evaluation

So, I'm being confused about foreign key constraint handling in Postgresql. (version 8.4.4, for what it's worth). We've got a couple of tables, mildly anonymized below: device: (id, blah, blah, blah, blah, blah x 50)… primary key on id …
user240438
4
votes
1 answer

Postgresql function stuck in for loop

The function is stuck just before the loop. select * from scm_main.fn_connection_stations(1219646) The message "Start..." is printed but message "... end" will not print. CREATE OR REPLACE FUNCTION …
mehrdad seyrafi
  • 3,084
  • 2
  • 19
  • 16
4
votes
2 answers

How to synchronize / limit certain async http calls in android

I am making use of the Android Async Http Library in my app to make async http requests. I have come into a situation in my android app where the following happens. My web api makes use of an access token and a refresh token. On every request that I…
Zapnologica
  • 22,170
  • 44
  • 158
  • 253
4
votes
5 answers

MySQL "LOCK TABLES" timeout?

What's the timeout for mysql LOCK TABLES statement? Can't find it anywhere. I tried to set variable innodb_lock_wait_timeout ini my.cnf but it seems it's related to another (row level) locking not to table locking. Simply it has no effect for LOCK…
luky
  • 2,263
  • 3
  • 22
  • 40
4
votes
1 answer

Kernel spin-lock enables preemption before releasing lock

When I was discussing the behavior of spinlocks in uni- and SMP kernels with some colleagues, we dived into the code and found a line that really surprised us, and we can’t figure out why it’s done this way. short calltrace to show where we’re…
Jan
  • 183
  • 1
  • 8
4
votes
1 answer

Personalized lock screen for Android

Hello I am looking for personalized screen locker for android phones, instead of typing numbers , user can flex fingers in a particular pattern and unlock the screen. Any pointers/ideas are appreciated.
David Prun
  • 8,203
  • 16
  • 60
  • 86
4
votes
2 answers

Multiple conditions vs Multiple locks

For a particular thread-safe data structure, I am needed to protect access to a central data structure (namely a byte array). I am choosing to use ReentrantLocks in this case for it's fairness policy as well as advanced capabilities with creating…
initramfs
  • 8,275
  • 2
  • 36
  • 58
4
votes
3 answers

Is this a dangerous locking pattern?

I have an enumerator written in C#, which looks something like this: try { ReadWriteLock.EnterReadLock(); yield return foo; yield return bar; yield return bash; } finally { if (ReadWriteLock.IsReadLockHeld) …
Martin
  • 12,469
  • 13
  • 64
  • 128
4
votes
2 answers

ReentrantReadWriteLock multiple reading threads

Good Day I have a question relating ReentrantReadWriteLocks. I am trying to solve a problem where multiple reader threads should be able to operate in parallel on a data structure, while one writer thread can only operate alone (while no reader…
Kugelblitz
  • 582
  • 5
  • 24
4
votes
3 answers

Let thread A block B & C and vice versa, but not let thread B block thread C and vice versa?

I have a problem where I have a datastructure and multiple threads trying to do operations on it. To say it as simple as possible: I have thread A, B and C. Thread A can only do its operation, as long as B and C are not making any changes to the…
Kugelblitz
  • 582
  • 5
  • 24
1 2 3
99
100