• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

deadlock ...

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi , I got the concept of deadlock but I am not able to figure out what could be the example for that .

can any body help me .
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow! You are certainly asking a large number of thread questions...

Anyway... classic case.

- thread 1 calls synchronized method of class a
- thread 2 calls synchronized method of class b

Hence, thread 1 owns lock a, and thread 2 owns lock b.

- thread 1 in method of class a tries to call synchronized method of class b. it will block because thread 2 owns lock b.

- thread 2 in method of class b tries to call synchronized method of class a. it will block because thread 1 owns lock a.

Hence, thread 1 owns a and waiting for b, thread 2 owns b and waiting for a. Neither will release their lock because it is waiting for the other one.

Henry
 
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic