Solved

synchronized block

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maven project error 5 54
Java SE 8u111  Lot of stuff broke 11 68
hibernate example using maven 12 41
runtime exception 2 27
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
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.

786 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