Solved

synchronized block

Posted on 2003-10-22
1
313 Views
Last Modified: 2010-03-31
Hi all

what will happen to a thread in the follwoing block:

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

0
Comment
Question by:dannysh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 16

Accepted Solution

by:
imladris earned 40 total points
ID: 9599137
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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question