Questions tagged [deadlock]

Situation where two (or more) operations need overlapping sets of resources, and neither can complete because they cannot obtain all locks necessary to complete an operation and release their locks.

Deadlock is situation where multiple operations are waiting for same resource(s) while simultananeously holding other resources that other threads holding the desired resources are waiting for.

For example, given resources A,B,C and processes 1,2.

  1. 1 locks A and B
  2. 2 locks C
  3. 2 needs A to finish
  4. 1 needs C to finish.

Neither 1 or 2 can release resources before finishing. Therefore, deadlock occurred.

The classical solution to all deadlock problems is to always acquire the resources in the same order in all threads or processes.

Reference

Deadlock in Wikipedia

3451 questions
1
vote
1 answer

How to prevent deadlocks in synchronized methods?

In the following Code there is a potential to enter a Deadlock similar to this Question "Deadlocks and Synchronized methods", now i understand why the two Threads are entering a deadlock, but when i execute the code the Threads always enters a…
proless8
  • 57
  • 1
  • 9
1
vote
0 answers

Xamarin HttpClient.PostAsync deadlock

We are having issue with System.Net.Http.HttpClient class. The code mentioned below is working fine with many Android devices except some, out of which two devices are listed below. The execution gets stuck on following line blocking the thread that…
1
vote
1 answer

How to avoid a deadlock caused by a thread panic?

My server uses a Barrier to notify the client when it's safe to attempt to connect. Without the barrier, we risk failing randomly as there is no guarantee that the server socket would have been bound. Now imagine that the server panics - for…
Svetlin Zarev
  • 14,713
  • 4
  • 53
  • 82
1
vote
1 answer

WCF service completely locked

I have a WCF service configured like this: InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple I have a method where I call the service about ten times per second for about 30 seconds. Randomly, the service…
Jean-Philippe Leclerc
  • 6,713
  • 5
  • 43
  • 66
1
vote
0 answers

iOS handle keychain cause deadLock?

I received a crash report as follow,is this handle keychain cause deadlock?
apricot
  • 434
  • 1
  • 4
  • 10
1
vote
2 answers

Will this method work thread-safe and without Deadlocks

public int saveUserToMap(User user) { ReentrantLock lock; if(this.userLocks.containsKey(user.getId())) { lock = this.userLocks.get(user.getId()); } else { lock = new ReentrantLock(); ReentrantLock check =…
Nightloewe
  • 918
  • 1
  • 14
  • 24
1
vote
2 answers

List and kill all dead lock queries in PostgresSQL

I want to clean my DB processes in PostgreSQL because few queries are in deadlock situation and as a result whole database is slowing down. So I want to know the best practice to list all deadlock queries and clean them regular basis. I got this…
Md Sirajus Salayhin
  • 4,974
  • 5
  • 37
  • 46
1
vote
4 answers

Await Task hangs if creating a new form instance before running the task

My await code hangs if I run a create a new form instance before running the await code. If I comment the line Form frm = new Form(); the code will be run properly otherwise it will hang in the code await Task.Delay(2000);. Another solution is to…
Lily Liu
  • 35
  • 5
1
vote
2 answers

Behavior async await console application vs. WPF

I am quite new to async await. I think I understood the example of the console application. When transferring the identical code to the WPF, there is a deadlock and I do not know exactly why. // All as expected // Output: // LongOperationAsync…
A5000
  • 11
  • 1
1
vote
2 answers

Swift - How to prevent DispatchQueues from executing on the same thread?

I have been learning about threading and DispatchQueues a lot recently and have come to a big question. I have heard many times that GCD makes no guarantees about which thread a given block of work may be executed on. Most of the time, this is a…
1
vote
4 answers

Understanding deadlock with a simple example

I am working on understanding deadlock basics so I came up with below code. I have two threads acquiring locks in opposite order but they're not deadlocking. When I run it I see all the printouts. What am I doing wrong? public class DeadlockBasics…
flash
  • 1,455
  • 11
  • 61
  • 132
1
vote
2 answers

Resolving deadlock - SQL Server

I am getting a deadlock between these 2 queries from 2 separate stored procedures: 1. UPDATE ord SET [Num] = @Num, [Ref] = @Re, [Date] = @Date FROM [Order] ord INNER JOIN [Orders_Open] oo ON oo.Id = ord.ID 2. UPDATE oo SET…
Ryan Gadsdon
  • 2,272
  • 4
  • 31
  • 56
1
vote
2 answers

Is it possible for two threads to face deadlock with a single object instance?

As far as I know,two threads need at least two objects and a cycle wait situation to face deadlock.But is it possible for two threads to face deadlock centering one object instance?
1
vote
0 answers

How to set a timeout for a lock (that has been acquired)?

I am recently working on a multithreaded project, and come across with a problem. SafeCreateProcessThread(); is being called every 220ms as long as the sensor is streaming. public void StreamingDisplayMonitor() { var dtStartTemp =…
Winfred
  • 19
  • 6
1
vote
1 answer

Deadlock in SQL 2008 on insert and update

I am getting a deadlock on concurrent users for insertion on my table. The sp which I am firing is relatively simple SET NOCOUNT ON; begin try begin tran DECLARE @idoc INT declare @ProcessedResponse table ( candidateInstanceID …
Nikshep
  • 2,117
  • 4
  • 21
  • 30
1 2 3
99
100