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
1 answer

Are atomics or mutex locks a must for display tasks in multi threading applications?

I'm using C++11 and the built-in threading class std::thread. Using std::atomic or std::mutex makes it easy to synchronise data, but I'm wondering if it is really necessary for "non sensitive" tasks - while maintaining a bug-free application. Let's…
Clemens
  • 313
  • 4
  • 15
4
votes
1 answer

Database: Are there any vendors support column level locking?

I'm studying about database mechanism and see that there are two mechanisms: table level locking and row level locking. I don't see column level locking and when I google, I see no document tell about this except this link: database locking. In this…
Trần Kim Dự
  • 5,872
  • 12
  • 55
  • 107
4
votes
2 answers

SQLite non-exclusive RESERVED lock?

I've been looking into improving SQLite performance for my site, especially with regard to transactions. In essence what I'm looking for is a way to defer database writes in a process so that they can all be done at once. However, while I'm…
Kyle Cronin
  • 77,653
  • 43
  • 148
  • 164
4
votes
2 answers

addAll() in LinkedBlockingQueue is thread safe (and solution if it's not)?

Quoting the documentation: "BlockingQueue implementations are thread-safe. All queuing methods achieve their effects atomically using internal locks or other forms of concurrency control. However, the bulk Collection operations addAll, containsAll,…
justHelloWorld
  • 6,478
  • 8
  • 58
  • 138
4
votes
5 answers

Is the "lock" statement in C# time-consuming?

I have a method which has been called many times by other methods to hash data. Inside the method, some lock statements are used. Could you please let me know whether the lock statement is time-consuming and what is the best way to improve it. P/S:…
Mark Attwood
  • 4,206
  • 5
  • 27
  • 24
4
votes
1 answer

Why this lock statement doesn't work?

why this lock test doesn't work ? it's throwing an exception bellow Console.Write that collection was modified.... static List staticVar = new List(); static void Main(string[] args) { Action>…
Alexandre
  • 7,004
  • 5
  • 54
  • 72
4
votes
3 answers

ASP.net cache access causing Collection Modified exception in foreach loop

Ok first things first. This is some exception information given by the support team. I know the line and code where it happens. It happens in a FirstOrDefault call over a dictionary obtained from cache. 1) Exception…
4
votes
3 answers

Scope of synchronization on .class objects in the JVM

Let's say I've got the following code: synchronize (Test.class) { ... } Does this mean that the Test.class objects is locked for every other program running in the same virtual machine? Or does this lock only affect this one program in the…
Harold L. Brown
  • 8,423
  • 11
  • 57
  • 109
4
votes
1 answer

what happens when the tasklet is interrupted by a hardware interrupt?

I wanted to know this part. We know that tasklets can't sleep, then if the HW interrupt comes in what happens to the tasklets? I am facing a crash, in which the tasklet is interrupted by a hW interrupt. I have used spinlock in my tasklet. Should I…
Invictus
  • 2,653
  • 8
  • 31
  • 50
4
votes
1 answer

Is lock() type-cast safe?

public class A { } public class B:A { } void foo() { A a = new B(); B b = a as B; } for a given instance setup, will lock(a) be equivalent to lock(b) ? I mean, will locking be mutually exclusive? If I lock(a) in one thread and lock(b) in…
Andy
  • 2,670
  • 3
  • 30
  • 49
4
votes
1 answer

how do python locks know which resource or object to lock? (THEORETICAL)

just to be clear i dont have a specific example because using the way various "how to"'s suggested to implement suited my needs until now and i did not encounter any problems regarding locks, but the usage of locks in python did raise the following…
user3371266
  • 69
  • 1
  • 9
4
votes
2 answers

Method for SharePoint list/item locking across processes/machines?

In general, is there a decent way in SharePoint to control race conditions due to two processes or even two machines in the farm operating on the same list or list item at the same time? That is, is there any mechanism either built in or that can…
Steve
  • 2,396
  • 2
  • 15
  • 16
4
votes
3 answers

Is locking instance or member based

I have a question about locking in c#. Does c# lock an instance of an object, or the member. If i have the following code: lock(testVar) { testVar = testVar.Where(Item => Item.Value == 1).ToList(); //... do some more stuff } Does c# keep…
BendEg
  • 20,098
  • 17
  • 57
  • 131
4
votes
1 answer

How do I make a checkbox in jQuery lock a existing sliding window from moving and then unlock it by unchecking the box?

I`m very new to jQuery but am starting to get the hang of it. My Question is: How do I make a checkbox in jQuery lock a existing sliding window function from moving and then unlock it by unchecking the box? So basically enable/disable a…
4
votes
1 answer

How to handle org.eclipse.persistence.exceptions.OptimisticLockExceptio

I want to handle concurrent execution by using Optimistic Locking. I have included @Version annotation in my entity class. In my code I am running two threads concurrently. Sometimes it is executing correctly. Sometimes it is throwing…
1 2 3
99
100