• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

What is Reentrancy?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

What is Reentrancy? How does Reentrant lock differ from ordinary synchronized block. pl explain
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reentrancy as the name suggests is the process of entering into a place again!

W.R.T locks, it is the time when a thread wants to reacquire the same lock.

So, if i say,



If reentrancy is not allowed then the above code will result in a deadlock as the thread is trying to acquire a lock which is already acquired.

Synchronized block is also reentrant. ReentrantLocks are named in such a way to be explicit about the nature of the lock.
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
one obivious diffrence between synchronized and reentrantlock is that you can have control how to lock it (you can use trylock) and the policy (fair or not fair) to lock it. the java doc should provide the details.
reply
    Bookmark Topic Watch Topic
  • New Topic