synchronized block

Hi all

what will happen to a thread in the follwoing block:

synchronized (this) {
............
   synchronized(this) {
                ............
   }
}

dannyshAsked:
Who is Participating?
 
imladrisCommented:
Nothing. Since the thread already owns the monitor, the second synchronization will have no effect.

Or, to put it another way, the *first* synchronize statement will force the thread to wait for the monitor for this object. Once it has it, it will continue executing. The *second* synchronize statement will never cause a block, because it already has the monitor for this object.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.