locking

Can I put a return statement inside a lock

Dupe: return statement in a lock procedure: inside or outside The title is a little misleading. I know that you can do it, but I'm wondering about the performance implications. consider these two blocks of code. (no error handling) This block has the return outside of the lock public DownloadFile Dequeue() { DownloadFile toRet...

Why does compiling my Biztalk 2009 project lock files?

Once you first build your BizTalk projects, the next time you go to make a change in one of the assemblies and then rebuild the solution the project output dlls are all locked by visual studio. Error 11 Unable to copy file "obj\Debug\Mits.Rar.Schemas.dll" to "bin\Debug\Mits.Rar.Schemas.dll". The process cannot access the file 'bin...

Object locking in Java

I have a class which contains a static collection that can be used across all threads. It acts as a cache. When it is first loaded from the database, it is supposed to never change. However, in rare cases, we have to clear this cache. The current way to do this is to restart the server. I want to implement a clear cache method. What is t...

Using SQL Server as resource locking mechanism

Given a table of logical resource identifiers (one per row), what is the best way for an arbitrary number of database clients to perform the following operations: Claim access to a specific resource, if it is not already claimed SELECT the next available resource and claim it (similar to above) Release a previously-claimed resource (...

Web front-end design for concurrent modification

Hi Experts, I am creating a web application which has a few management screens, where a user can go to edit records (for example, changing the contact details of a user). Access to these managements screens are controlled by roles, with multiple users possibly having access. The problem now arises of what to do if two users simultaneous...

How do I track down what's re-enabling triggers during my SQL*Loader load?

I seem to be seeing a lot of messages like this in my log: Trigger DEV."MBR_TRG" was disabled before the load. Trigger DEV."MBR_TRG" was re-enabled by another process. SQL*Loader-951: Error calling once/load initialization ORA-00604: error occurred at recursive SQL level 1 ORA-00054: resource busy and acquire with NOWAIT specified Thi...

Can Oracle's default object lock timeout be changed?

> ALTER PACKAGE blah COMPILE; (wait about 10 minutes) > ORA-04021: timeout occurred while waiting to lock object I understand why I get the timeout error (the package is in use). Does anyone know if there's a way to change the default 10 minute wait interval? Can this be configured at a database / session / statement level? Thanks ...

Release multiple locks atomically in Java

If I have acquired a number of locks, how do I release the Set of locks atomically? ...

How to implement pessimistic locking in JPA with Glassfish 2.1?

When trying to setup a lock (pessimistic), with the following code: em.lock(controlnumbers, LockModeType.WRITE); em.refresh(controlnumbers); I am getting the following exception: [#|2009-09-10T15:42:48.324-0400|INFO|sun-appserver2.1|javax.enterprise.system.container.ejb|_ThreadID=31;_ThreadName=httpSSLWorkerThread-8080-19;| javax.ejb...

When to use pessimistic concurrency?

What are specific scenarios where pessimistic concurrency is used? ...

Locking in sqlalchemy

I'm confused about how to concurrently modify a table from several different processes. I've tried using Query.with_lockmode(), but it doesn't seem to be doing what I expect it to do, which would be to prevent two processes from simultaneously querying the same rows. Here's what I've tried: import time from sqlalchemy.orm import session...

Is this thread safe?

private static bool close_thread_running = false; public static void StartBrowserCleaning() { lock (close_thread_running) { if (close_thread_running) return; close_thread_running = true; } Thread thread = new Thread(new ThreadStart(delegate() { while (true) { lock (close_thread_running) { ...

SQL Server Compact timed out waiting for a lock

Hi all, I'm having an application in that i use Sql Compact 3.5 with VS2008. I'm running multiple threads in my application which contacts the compact database and accesses the row. It selects and deletes those rows in a fashion i.e selecting and giving to the application 5 rows and deleting those rows from the table. It works great with...

mysql error: Lock wait timeout exceeded

I'm using mysql together with asp.net on my webserver. I also use a sqlite database to be able to use the database on another device. I need to send data between the two databases. This is something that needs to be done many times a day. This is an example of how I do it: using (MySqlTransaction mysqltransaction = mysqlconn.BeginTr...

How to delete a file which is locked?

I am writing a desktop application under Windows in C++ MFC. The application creates a index file, and writes information to it again and again. If the application crashes, the next time the application starts it will delete the crashed index file and create a new one. I think in certain cases, the index file will be locked. It will be...

Mutating a lock object

Hi Guys Just curious to know (in as much detail as possible), why is it a bad practice to modify the object while using it as a lock. //Assuming the lockObject is globally available synchronized(lockObject){ lockObject.someMutativeOperation(...); } Cheers ...

Why do reads block other reads in MyISAM?

I have one really long running read. It is a cronjob run once a day, but the whole DB gets locked down when it is running : mysql> show full processlist; +--------+------+-----------+------+---------+------+--------------+--------------------------------------------------------------------------------------------------------------------...

Lock across several jvm ?

Hi, this is a bit related to this question. I'm using make to extract some information concerning some C programs. I'm wrapping the compilation using a bash script that runs my java program and then gcc. Basically, i'm doing: make CC=~/my_script.sh I would like to use several jobs (-j option with make). It's running several processe...

Spinlocks, How Much Useful Are They?

How often do you find yourself actually using spinlocks in your code? How common is it to come across a situation where using a busy loop actually outperforms the usage of locks? Personally, when I write some sort of code that requires thread safety, I tend to benchmark it with different synchronization primitives, and as far as it goes,...

Truncating MEMORY table, and locking

I use a 1 column memory table to keep track of views on various items in my DB. Each view = INSERT query into the memory table. Every 10 mins, I wanna count() the rows for each item, and commit changes to DB. The question is.... if I run the query that will get the list of all items, such as SELECT COUNT(*) AS period_views, `item_id` F...