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

What is a class component?

877


What is difference between == and === in js?

803


Name some classes present in java.util.regex package.

825


Can static methods access instance variables in java?

806


What is java util list?

682


What is finalize()?

891


Should database connections be singleton?

781


what are the states associated in the thread? : Java thread

842


What is boolean strategy?

893


Differentiate between a class and an object.

813


What are dot operator queries?

876


Differentiate between nested and inner class in java.

787


How can we find the actual size of an object on the heap?

1084


What is ascii format?

776


Why does it take so much time to access an applet having swing components the first time?

1692