Solved

synchronized block

Posted on 2003-10-22
1
303 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
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
mergeTwo  challenge 13 71
triangle challenge 4 77
sumDigits  challenge 7 60
count8 challlenge 13 85
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

708 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now