A lock generally refers to something that prevents another process from starting or accessing the same information until the lock is released. Use with an appropriate language tag. Do not use for physical locks.
Questions tagged [locks]
433 questions
0
votes
2 answers
Can multilevel locks cause deadlocks in multithread programs?
I have a program with writers and readers and their access right is controlled by a monitor.
So, this was supposed to starve, but I got a deadlock. I was wondering why and then I remembered that I put another lock, which I think was unnecessary…

user2967016
- 133
- 1
- 9
0
votes
1 answer
private lock object and client side lock
When to use private lock object to synchronize a block?
Object lock =new Object();
synchronized(lock)
{ }
When to use client side lock to synchronize a block?
private final List ips =
Collections.synchronizedList(new ArrayList<…

Sameer Sarmah
- 1,052
- 4
- 15
- 33
0
votes
1 answer
Query hangs out
This code is working:
CREATE SYNONYM S FOR [ServerIP].[MyDatabase].[dbo].[MyTable]
SELECT * FROM S
DROP SYNONYM S
And this one is not working.
BEGIN TRAN
CREATE SYNONYM S FOR [ServerIP].[MyDatabase].[dbo].[MyTable]
SELECT…

bjnr
- 3,353
- 1
- 18
- 32
0
votes
1 answer
Hardware/software interrupts
When a host machine sends an interrupt to a device (over say, PCI bus) by writing to a register on the device running an RTOS, is it considered a hardware or a software interrupt? Looking for some elaborate explanation.

AbhinavChoudhury
- 1,167
- 1
- 18
- 38
0
votes
0 answers
Read locks and concurrency
I read on SO in an answer of a question:
"A lock allows only one thread to enter the part that's locked" and many people have voted that up. The answer further scales up the definition to explain mutex and semaphore.
In another place (on SO as well…

Atul
- 3,778
- 5
- 47
- 87
0
votes
1 answer
Reentrant lock await and signalAll methods
Why the following very simple code does not work.. it gets stuck..
I am trying to use the explicit lock java.util.concurrent.locks.ReentrantLock; and its newCondition() method.
Here is my code:
import java.util.concurrent.locks.Condition;
…

Rollerball
- 12,618
- 23
- 92
- 161
0
votes
1 answer
Two threads, two synchronized blocks and one intrinsic lock
I wrote a code snippet that starts two threads; one thread prints all odd numbers while another thread prints all even numbers.
I used a combination of intrinsic lock and thread communication commands to achieve proper interleaving of my two…

user2581707
- 15
- 3
0
votes
1 answer
Python Threadsafe Integer Decrease using locks
I have several workers process which should decrease a shared integer when the are finished.
To ensure Threadsafety i tried a lock but somehow it is not working, printing out workers at the end of the program will still output 4
I read…

Dukeatcoding
- 1,363
- 2
- 20
- 34
0
votes
1 answer
which type of lock mechanism to use in shared library ie accessed by posix threads
I have an application using posix threads ie using a static library which has some global variables and I dont have any thread implementation in libray.
Somebody told me you should use pthread_mutex if you are using pthreads in that file else simple…

linuxD
- 229
- 1
- 3
- 10
0
votes
1 answer
Spring batch jobs simultaneously access database locks
I have two Spring Batch jobs: first one (job A) reads data from a CRM system (thru web services) and writes it to Oracle database table; second one (job B) - vise verse - reads data from same Oracle database table and sends it to CRM (thru web…

user2382219
- 1
- 1
- 1
0
votes
1 answer
Way to work with threads properly in C#
I have some difficulties designing the way my code should work:
Serial #1 (receives data at any time) invokes Routine() if some particular received value A is > constant1, but only if Routine() is not running, otherwise ONLY the last invocation…

eried
- 398
- 5
- 15
0
votes
1 answer
Does merge replication lock subscriber database?
I need to configure merge replication between 2 databases. These databases have foreign key integrity, which makes the replication not work, so I resorted to:
Dropping all FKs on subscriber database,
Replicating, and
Recreating the FKs.
This…

Georgi Gamzakov
- 11
- 4
0
votes
1 answer
Locks and Delete In sqlserver when there are no rows to delete
Using SqlServer2012, Is there any advantage in calling
if exists (select * from tablename where condition) begin
delete tablename where condition
end
over just calling
delete tablename where condition
When there often won't be any rows…

Stuart Moore
- 681
- 5
- 32
0
votes
1 answer
Queries blocking each other
I am logged into my application from system. I perform refresh from one user and copy paste
from the other. refresh has mainly a set of select queries and copy paste is having more of insert queries.
refresh as such takes one minute or less to…

jetty
- 859
- 2
- 17
- 37
0
votes
1 answer
multiple threads but only one allowed to use method
So basically the situation I am in is I have a bunch of threads each doing different calculations throughout the week. At the end of the week, every thread calls function X() and then starts calculating for the next week and repeats this cycle.…

user1782677
- 1,963
- 5
- 26
- 48