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
5 answers

Highly unusual situation - Thread blocked on a lock which it is holding?

This java program I am working on seems to hang on startup, so I tried using jconsole to debug the problem. As it turns out it is waiting on a call to a method which is declared as - synchronized void stopQuery() But here is the crazy part, the…
pdeva
  • 43,605
  • 46
  • 133
  • 171
4
votes
1 answer

Postgres Advisory Locks not working

I am having issues with postgres advisory locks not acquiring correctly on postgres 9.4.4. If I ssh into a postgres server on two screens and open psql to acquire a lock on one and attempt to aquire the lock on another it works perfectly. However,…
Jared Mackey
  • 3,998
  • 4
  • 31
  • 50
4
votes
1 answer

WIll Select for update wait locks the rows permanently?

I have two processes accessing the same table. Each of them runs a select for update query and the WAIT value is set. My question is: if process one runs the query and locks n rows in the table, how can the rows get released if process one crashed…
xcoder
  • 1,336
  • 2
  • 17
  • 44
4
votes
2 answers

How to multi-thread "Cross-tier" a singleton with a correlation id without locking?

So we are using a common state context singleton with a correlation ID for centralized Logging. The purpose is to track the id throughout our entire process and correlate the different tiers. The state context is accessed by multiple dlls and…
Demodave
  • 6,242
  • 6
  • 43
  • 58
4
votes
2 answers

How can I ensure thread safety in the following context?

I have a method called processOutbox. I want it to be thread safe. I don't want another thread to call this method while one thread is at it. I have implemented it the following way. Have I done it correctly? Are there any loopholes in my…
AnOldSoul
  • 4,017
  • 12
  • 57
  • 118
4
votes
2 answers

Correct way to use the Interlocked class for multithreading in .NET

I have a counter, which counts the currently processed large reports private int processedLargeReports; and I'm generating and starting five threads, where each thread accesses this method: public bool GenerateReport(EstimatedReportSize…
Osman Esen
  • 1,704
  • 2
  • 21
  • 46
4
votes
2 answers

Delete locked Access database

I have an Access database (.accdb) file that must be replaced with a backup copy. Unfortunately, the file is locked with an (.laccdb) and I cannot rename or remove either file. I don't exactly know who is locking the file and it could be…
cheezsteak
  • 2,731
  • 4
  • 26
  • 41
4
votes
2 answers

Check whether a row or range of rows is locked in a table for MySql database?

From java using MySql database, how can check whether a row or range of rows is locked in a table ?
Muhammad Ali Qasmi
  • 121
  • 1
  • 1
  • 6
4
votes
1 answer

SQL Server : lock table to block other sessions trying to read the table

I need to be able to lock a table in SQL Server while doing some work. The lock needs to block other sessions from reading the table. When the work is complete the table needs to be unlocked. In MySQL I have done this by using: LOCK TABLES [table]…
sjallamander
  • 439
  • 2
  • 6
  • 20
4
votes
2 answers

Hibernate and Concurrency

I have already read the hibernate docs about concurrency and I think, I have understood the available locking methods, but I am not sure how I should implement the following scenario. Two clients F (fast) and S (slow) access the database and can…
Karussell
  • 17,085
  • 16
  • 97
  • 197
4
votes
1 answer

Google Apps Script: append row to spreadsheet and get last row

I have a new Google App Script project, which includes a form (not Google Form) which allows user to enter data. The data will be submitted and inserted to a Google Spreadsheet. I want to give each user an unique ID which is last row + 1. I tried…
user3545752
  • 351
  • 1
  • 7
  • 15
4
votes
1 answer

stream_set_write_buffer or file locking in PHP?

I'm trying to make a caching system where a large chunk of data (between 8 KB and 200 KB) can be written as fast as possible. Currently I'm applying file locking functions using the code similar to…
Mike -- No longer here
  • 2,064
  • 1
  • 15
  • 37
4
votes
2 answers

IllegalMonitorStateException on a synchronized call to a Lock Condition's signalAll()

I have: static public final ReentrantLock lock = new ReentrantLock(); static public Condition my_condition = lock.newCondition(); in myClass_1 and in myClass_2 class I call: synchronized (myClass_1.my_condition){ …
Maths noob
  • 1,684
  • 20
  • 42
4
votes
0 answers

A suspended transaction release the "select for update" lock?

Transaction A(PROPAGATION_REQUIRED) { lock = "select * from lock_table while id = 1 for update" Method son(){ Transaction B(PROPAGATION_REQUIRES_NEW){} } } I know that PROPAGATION_REQUIRES_NEW will suspend the…
amanda
  • 41
  • 1
4
votes
4 answers

Static members need special synchronization blocks?

I have a class which looks something like this: public class Test { private static final Object someObject = new Object(); public void doSomething() { synchronized (someObject) { System.out.println(someObject.toString()); …
Yuval Adam
  • 161,610
  • 92
  • 305
  • 395