locking

The best way to design a Reservation based table

One of my Clients has a reservation based system. Similar to air lines. Running on MS SQL 2005. The way the previous company has designed it is to create an allocation as a set of rows. Simple Example Being: AllocationId | SeatNumber | IsSold 1234 | A01 | 0 1234 | A02 | 0 In the process of selling a s...

Iphone screen lock/off and then no sound

My app is playing music, when the screen get lock/off, SOMETIMES there will be no sound. Why? Tnx ...

Locking strategy with PropertyChangeListener

I've defined a class with a number of "observable" properties. Internally the class contains a single thread that performs I/O; e.g. public class Foo { private final PropertyChangeSupport support; private State state; public Foo() { this.support = new PropertyChangeSupport(this); } public synchronized State getState() { retur...

Cocoa Lock that does not use cpu power

Hi, I need a lock in cocoa that does not use one cpu when I try to lock it and it is locked somewhere else. Something that is implemented in the kernel scheduler. ...

C# - Locking a resource when obtained from dictionary

I have a Dictionary that tracks objects (ClientObject). Both the dictionary and ClientObject's are accessed by multiple threads. When I modify or read any object in this dictionary, I obtain a read or write lock on the dictionary using ReaderWriterLockSlim (rwl_clients) then obtain an exclusive lock on the actual object. I just wanted t...

Exclusive table (read) lock on Oracle 10g?

Is there a way to exclusively lock a table for reading in Oracle (10g) ? I am not very familiar with Oracle, so I asked the DBA and he said it's impossible to lock a table for reading in Oracle? I am actually looking for something like the SQL Server (TABLOCKX HOLDLOCK) hints. EDIT: In response to some of the answers: the reason I nee...

C# Locking, Properties & Permissions

I've been using lock on value type properties when multi-threaded access is required. Also, I've been meaning to become more diligent about applying proper access modifiers, especially in my library code that is starting to become useful in multiple projects. I've written some code and would like to request comments on the various stra...

thread(?) database locking(?) in rails

Say I have this method: def create_registration_unless_over_limit if Registration.count < 50 Registration.create! else raise "too many registrations" end end How do I ensure that I never have >= 50 registrations considering that I have more than one rails process running? Theoretically, isn't it possible that two reques...

How to achive single-processing mode running php scripts?

I have cron job - php script which is called one time in 5 minutes. I need to be sure that previously called php script has finished execution - do not want to mix data that's being processed. There are three approaches I used to apply: Creation of auxiliary text file which contains running-state flag. Executed script analyzes the co...

Clarification on DBMS Locking

I'm taking an intro class on database management systems, and had a question that wasn't answered by my book. This question is not from my homework, I was just curious. The textbook continually stresses that a transaction is one logical unit of work. However, when coming across the shared/exclusive locking modes, I got a little confused...

checking if a file locked in java

Hello, I plan my java program to read a file which can be locked by another program to write into it so I need to check if the file is locked, if so wait until it is free and execute X function when free. How to achieve this? ps: the enviroment that my java program will run will be a Windows 2000 server ...

understanding Locking help?

I'm creating an ASP.net website which handles thousands of requests and it all stems from one main object that they all share to read it. I'm trying to wrap my head around these different types of locks. Some common questions i have for each. What is the scope of each lock Application, Session,Object When is it right to use one over t...

How to check if a table is locked in sql server

I have a large report I am running on sql server. It takes several minutes to run. I don't want users clicking run twice. Since i wrap the whole procedure in a transaction, how do I check to see if the table is locked by a transaction? If so I would want to return an error message saying "report generating, please try again in a few min...

--single-transaction --lock-tables options of mysqldump- what happens internally?

Hello, I did find other posts similar to this, but wanted a little extra information on these options of mysqldump. I have understood that the --single-transaction and --lock-tables are mutually exclusive operations. Following are my questions regarding these options. a) Suppose I have chosen to use --lock-tables option. In this case t...

How do I lock the console across threads in C#.NET?

Hello :) I have a logger class that handles various information display with pretty colors (yay.). However, since it writes to the console in separated steps (i.e. set color to red, write text, set color to gray, write text, for something that would render "[Error] Description..." with the error being in red), but I have a multithreaded...

Is it possible in DB2 or in any Database to detect if the table is locked or not?

Is it possible in DB2 to detect if the table is locked or not. Actually whenever we use Select statement and if that table is locked [ may be because of on going execution of insertion or deletion ] , then we have to wait till the table is unlocked. In our application sometimes it goes to even 2-3 mins. What i think is, if i can have s...

What effect does HOLDLOCK have on UPDLOCK?

I have seen many examples of the HOLDLOCK hint being used in combination with UPDLOCK (like this). However as I read the documentation for these hints, it seems that HOLDLOCK should be redundant, since UPDLOCK already persists the lock until the end of the transaction. (Also it seems to say that HOLDLOCK only applies to shared locks anyw...

HttpApplicationState - Why does Race condition exist if it is thread safe ?

I just read an article that describes how HttpApplicationState has AcquireRead() / AcquireWrite() functions to manage concurrent access. It continues to explain, that in some conditions however we need to use an explict Lock() and Unlock() on the Application object to avoid a Race condition. I am unable to understand why a race conditi...

What happens if I lock an object while another thread use that variable?

I am not sure how lock works. What happens if I have a List<T> list and 2 threads ? What happens if thread1 start running first and enumerate that list foreach(T t in list) { // code } and in the same time, but after thread1 has started, thread2 will lock the list lock(list) { // code } I use ThreadPool do to some processing a...

DataReader Behaviour With SQL Server Locking

We are having some issues with our data layer when large datasets are returned from a SQL server query via a DataReader. As we use the DataReader to populate business objects and serialize them back to the client, the fetch can take several minutes (we are showing progress to the user :-)), but we've found that there's some pretty hard-c...