locking

How do I synchronize (lock/unlock) access to a file in bash from multiple scripts?

I'm writing scripts that will run in parallel and will get their input data from the same file. These scripts will open the input file, read the first line, store it for further treatment and finally erase this read line from the input file. Now the problem is that multiple scripts accessing the file can lead to the situation where two...

What to pass to the lock keyword?

What is the difference (if any) between using void MethodName() { lock(this) { // (...) } } or private object o = new object(); void MethodName() { lock(o) { // (...) } } ? Is there a difference in performance? Style? Behaviour? ...

Using lock in a RCP/AWT application

Hi, We have some CRUD application but we don't want people to modify at the same time a object (dirty read & exception will occur) What is the best way to handle it ? (& framework) ...

Can An SQLite database be locked ? as in one cannot be opened externally and add rows to a table??

ok lets assume i have a table now it has only two rows in it and i dont want anyone to add any more rows to it? it can be accessed by c sharp but it should not be openable using SQLite admin or any other db manager , is that possible?? I dont want the user to add another row outside c sharp can this be done???? triggers??? ...

Lock, mutex, semaphore... what's the difference?

I've heard these words related to concurrent programming, but what's the difference between them? ...

Folder with sqlite db locked by explorer.exe after software uninstall

I have an uninstall issue with an app which is using sqlite: during installation a blank sqlite db is created in [CommonAppData]\MyApp\mydb.sqlite, e.g. C:\Documents and Settings\All Users\Application Data\MyApp\mydb.sqlite. When I uninstall my app it can't delete the sqlite db, despite it removing the applications that are connectng to...

Why does row level locking not appear to work correctly in SQL server?

This is a continuation from When I update/insert a single row should it lock the entire table? Here is my problem. I have a table that holds locks so that other records in the system don’t have to take locks out on common resources, but can still queue the tasks so that they get executed one at a time. When I access a record in this l...

Details of impact of different locking schemes in databases?

I'm testing different locking schemes for a big table, more than 4 million rows and expected to grow up to 10 million. My experience with SyBase: ALLPAGES, extremely slow BCP (in) and update with a field that belongs to the Primary Key. DATAROWS, fast BCP, fast update for fields in the PK, fastest select. DATAPAGES, fastest BCP and upda...

database record locking

I have a server application, and a database. Multiple instances of the server can run at the same time, but all data comes from the same database (on some servers it is postgresql, in other cases ms sql server). In my application, there is a process that is performed which can take hours. I need to ensure that this process is only execu...

Sybase: trying to lock a record on select so another caller does not get the same one

I have a simple table in Sybase, let's say it looks as follows: CREATE TABLE T ( name VARCHAR(10), entry_date datetime, in_use CHAR(1) ) I want to get the next entry based on order of "entry_date" and immediately update "in_use" to "Y" to indicate that the record is not available to the next query that comes in. The kicker i...

Java: what happens when a new Thread is started from a synchronized block?

First question here: it is a very short yet fundamental thing in Java that I don't know... In the following case, is the run() method somehow executed with the lock that somemethod() did acquire? public synchronized void somemethod() { Thread t = new Thread( new Runnable() { void run() { ... <-- is a lock...

Java: Is it common practice to create a new Thread when a lock is held?

Hi all, I've got a question related but not identical to my first question ever here: http://stackoverflow.com/questions/2340114/java-what-happens-when-a-new-thread-is-started-from-a-synchronized-block Is it a common practice to create and start() a new Thread when you're holding a lock? Would that be a code smell? Basically I've g...

What changes should be made to SQL Server’s locking architecture to make it more developer friendly?

I’ve lately come across a rather frustrating situation where SQL server refuses to issue locks only against a primary key when a statement like this select * from table with (rowlock updlock) where key=value is executed against it. Now don’t get me wrong here, it does lock the row but it goes one step farther and locks the table too. ...

calling a logger instance from a static method

Hello, I am writing a c# logger to be used in a busy, multi-threaded application. I want to create 5 different loggers, where each of the loggers handles logging for different functionality. The loggers will be called by static as well as nonstatic code. Since the loggers write to a file, I want to synchronize the file access using l...

How do I control the access of multiple threads to a collection of objects?

I'm writing an application that displays a list of objects which the user can select and then view and edit the properties of through a PropertyGrid control. The object's properties are populated by time consuming process of extracting information from files through the use of a secondary thread. But I'd also like to allow the user to co...

Cannot obtain shared variable value in separate threads

My program has a server thread and separate client threads that are individual connections to other servers. So how my program works is the client threads make individual requests, and when each of them so, I increment the shared variable iTimeStamp. However, I need to access this shared variable value through my Server thread, but when...

Block file during uploading on FTP

Hi all! I have two services client and server. Client upload file on some ftp and server download it. So there can occur situation when client do not finish upload file and server already start download this file. In that situation i have cuted file. How can solve it? For example when i upload and at the same time download it using Fil...

Concurrent appends to the same file using Perl

I have a need to upgrade a Perl CGI script where the users must complete 3 steps. After they finish each step, the script is logging which step the user completed. Having a record of this is important so we can prove to the user that they only finished step one and didn't complete all three steps, for example. Right now, the script is...

How to release a locked row using JPA?

I'm using the EclipseLink implementation of the JPA 2.0 which allows pessimistic locking. I know how to lock an entity but how do I release the lock? At first I thought this was all taken care of within a transaction (in other words, the entity is locked until you commit the transaction), but that does not seem to be the case. I tried...

How do you stop a user-instance of Sql Server? (Sql Express user instance database files locked, even after stopping Sql Express service)

When using SQL Server Express 2005's User Instance feature with a connection string like this: <add name="Default" connectionString="Data Source=.\SQLExpress; AttachDbFilename=C:\My App\Data\MyApp.mdf; Initial Catalog=MyApp; User Instance=True; MultipleActiveResultSets=true; Trusted_Connection=Yes;" /> We find that we can't ...