What are the two ways you can synchronize a block of code?

Answer Posted / ajay tiwary

The way you can synchronize the block is:-

synchronized(dummy object)
{
//synchronized statement

}
In dummy object you can use this or u can create a dummy
object by using new Keyword.

What answer Vikki is posted as the first one is not the way
of synchronizing the block but it's a way to synchronizing
a method.

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is static a keyword in java?

528


what is a green thread? : Java thread

576


What are the benefits of operations?

516


What are methods and how are they defined?

605


Is java util list serializable?

543






What is the size of a string in java?

549


What are the 4 types of research methods?

518


What is a text string?

629


Can constructor be synchronized?

547


What does s mean in regex?

555


What is the difference between && and & in java?

575


In the below example, how many string objects are created?

561


What is the use of static methods?

594


What is the difference between equals() and == in java?

531


What is the difference between an inner class and a sub-class?

510