• Post Reply Bookmark Topic Watch Topic
  • New Topic

reduce deadlock  RSS feed

 
abalfazl hossein
Ranch Hand
Posts: 635
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it right idea that in order to reduce chance of deadlock,reduce using of locks?
 
Stephan van Hulst
Saloon Keeper
Posts: 7817
142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Strictly speaking, the chance of deadlock goes up if you use more locks, yes.

However, you make it sound like you have a choice. There is no choice. If your program is multi-threaded, you need to use locks in those critical sections to guarantee that your program will run correctly. If you can reduce the number of locks in your program without sacrificing correctness, that means you were using too many locks in the first place.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!