Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

can a synchronized method block itself ?  RSS feed

 
Omar Al Kababji
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, i have a simple question. assuming the following piece of code




when writing the piece of code i was supposing that I would see a "I am executing" message on the console and then the program will get blocked, however no i got a stack overflow since the method didn't block itself and kept calling itself. could i have some explanation of what is happening?

Thanks,
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Locks are reentrant, meaning that if a thread already holds a lock, then the thread can acquire it again without blocking.
 
Omar Al Kababji
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ernest that clears everything
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!