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 the gregoriancalendar class in java programming?

564


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

800


Explain the importance of thread scheduler in java?

591


Describe the process as to how substring() methodology mechanisms in java.

554


What are sets in java?

500






what is an objects lock and which objects have locks? : Java thread

524


What is local class in java?

514


Why array is used in java?

509


When can an object reference be cast to an interface reference in java programming?

575


What is meant by tab pans?

643


Describe different states of a thread.

571


What does it mean to flush a file?

564


What is extension method in java?

559


What are predicates in java 8?

527


What is the original name of java?

535