Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deadlock in Single threaded application

Can a single threaded application have a deadlock? If so, please provide an example.

like image 809
swetha Avatar asked Jan 29 '10 15:01

swetha


2 Answers

Yes, a single-threaded application can deadlock if you have locks that are not re-entrant and a thread attempts to reacquire a lock that it owns already (like via a recursive call).

Edit: I see that the post has been tagged "Java"; I don't know if that was an update or if I missed it before, but in any case locks in Java ARE re-entrant, so you won't be able to deadlock a single-threaded application in this manner.

like image 165
danben Avatar answered Sep 28 '22 04:09

danben


Yes, if the application shares resources with another application it can be deadlocked.

like image 43
Jonas Avatar answered Sep 28 '22 03:09

Jonas